-
Notifications
You must be signed in to change notification settings - Fork 354
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Support MetadataFilters for Milvus and SimpleVectorStore (#1033)
Co-authored-by: Marcus Schiesser <[email protected]>
- Loading branch information
1 parent
4cc3c1b
commit 1ebc973
Showing
12 changed files
with
921 additions
and
68 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
--- | ||
"llamaindex": patch | ||
"@llamaindex/llamaindex-test": patch | ||
--- | ||
|
||
Add support for Metadata filters |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import { MilvusVectorStore, VectorStoreIndex } from "llamaindex"; | ||
|
||
const collectionName = "movie_reviews"; | ||
|
||
async function main() { | ||
try { | ||
const milvus = new MilvusVectorStore({ collection: collectionName }); | ||
const index = await VectorStoreIndex.fromVectorStore(milvus); | ||
const retriever = index.asRetriever({ similarityTopK: 20 }); | ||
|
||
console.log("\n=====\nQuerying the index with filters"); | ||
const queryEngineWithFilters = index.asQueryEngine({ | ||
retriever, | ||
preFilters: { | ||
filters: [ | ||
{ | ||
key: "document_id", | ||
value: "./data/movie_reviews.csv_37", | ||
operator: "==", | ||
}, | ||
{ | ||
key: "document_id", | ||
value: "./data/movie_reviews.csv_37", | ||
operator: "!=", | ||
}, | ||
], | ||
condition: "or", | ||
}, | ||
}); | ||
const resultAfterFilter = await queryEngineWithFilters.query({ | ||
query: "Get all movie titles.", | ||
}); | ||
console.log(`Query from ${resultAfterFilter.sourceNodes?.length} nodes`); | ||
console.log(resultAfterFilter.response); | ||
} catch (e) { | ||
console.error(e); | ||
} | ||
} | ||
|
||
void main(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.