Skip to content

Commit

Permalink
community[patch]: fix: ElasticVectorSearch: exclude metadata filters … (
Browse files Browse the repository at this point in the history
#6536)

* community[patch]: fix: ElasticVectorSearch: exclude metadata filters not working due to syntax error in filter creation

* Adds integration test

---------

Co-authored-by: Christoph Höller <[email protected]>
Co-authored-by: jacoblee93 <[email protected]>
  • Loading branch information
3 people authored Aug 16, 2024
1 parent c4cb3a0 commit 032c14b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion libs/langchain-community/src/vectorstores/elasticsearch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,7 @@ export class ElasticVectorSearch extends VectorStore {
});
} else if (condition.operator === "exclude") {
must_not.push({
terms: {
term: {
[metadataField]: condition.value,
},
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,14 @@ describe("ElasticVectorSearch", () => {
]);
const results = await store.similaritySearch("*", 11);
expect(results).toHaveLength(11);
const results2 = await store.similaritySearch("*", 11, [
{
field: "a",
value: createdAt,
operator: "exclude",
},
]);
expect(results2).toHaveLength(1);
});

test.skip("ElasticVectorSearch integration with text splitting metadata", async () => {
Expand Down

0 comments on commit 032c14b

Please sign in to comment.