add filter to milvus

This commit is contained in:
Henry 2023-09-15 00:32:52 +01:00
parent 0c71e62c2d
commit 18079d220e
1 changed files with 22 additions and 2 deletions

View File

@ -21,7 +21,7 @@ class Milvus_Existing_VectorStores implements INode {
constructor() {
this.label = 'Milvus Load Existing collection'
this.name = 'milvusExistingCollection'
this.version = 1.0
this.version = 2.0
this.type = 'Milvus'
this.icon = 'milvus.svg'
this.category = 'Vector Stores'
@ -50,6 +50,25 @@ class Milvus_Existing_VectorStores implements INode {
label: 'Milvus Collection Name',
name: 'milvusCollection',
type: 'string'
},
{
label: 'Milvus Filter',
name: 'milvusFilter',
type: 'string',
optional: true,
description:
'Filter data with a simple string query. Refer Milvus <a target="_blank" href="https://milvus.io/blog/2022-08-08-How-to-use-string-data-to-empower-your-similarity-search-applications.md#Hybrid-search">docs</a> for more details.',
placeholder: 'doc=="a"',
additionalParams: true
},
{
label: 'Top K',
name: 'topK',
description: 'Number of top results to fetch. Default to 4',
placeholder: '4',
type: 'number',
additionalParams: true,
optional: true
}
]
this.outputs = [
@ -70,6 +89,7 @@ class Milvus_Existing_VectorStores implements INode {
// server setup
const address = nodeData.inputs?.milvusServerUrl as string
const collectionName = nodeData.inputs?.milvusCollection as string
const milvusFilter = nodeData.inputs?.milvusFilter as string
// embeddings
const embeddings = nodeData.inputs?.embeddings as Embeddings
@ -109,7 +129,7 @@ class Milvus_Existing_VectorStores implements INode {
throw new Error(`Collection not found: ${vectorStore.collectionName}, please create collection before search.`)
}
const filterStr = filter ?? ''
const filterStr = milvusFilter ?? filter ?? ''
await vectorStore.grabCollectionFields()