ElasticVectorSearch: exclude metadata filters not working due to syntax error in filter creation #6535
Closed
5 tasks done
Labels
auto:bug
Related to a bug, vulnerability, unexpected error with an existing feature
Checked other resources
Example Code
The following code
where vectorStore is an instance of ElasticVectoreStore, leads to the error message:
Error Message and Stack Trace (if applicable)
The following error occured while executing the query: x_content_parse_exception\n\tCaused by:\n\t\tx_content_parse_exception: [1:17197] [bool] failed to parse field [must_not]\n\tRoot causes:\n\t\tparsing_exception: [terms] query does not support [metadata.gender.keyword]
Description
I'm using version 0.0.57 of @langchain/community package and I'm using the metadata filtering functionality of the
ElasticVectorStore
. This works for ordinaryterms
filters, but throws an error forexclude
filters. The reason is, that the methodElasticVectorSearch.buildMetadataTerms
contains a syntax error when creating themust_not
query part:In this snippet
the
terms
keyword needs to be replaced withterm
:see e.g. https://discuss.elastic.co/t/elasticsearch-query-multiple-must-nots/349570/6
System Info
npm version 10.5.0
node version 18.20.2
mac
The text was updated successfully, but these errors were encountered: