Hi,
I have these documents in my collection:
{
_id: ObjectId(),
text: "Bye bye",
embedding: Array,
id: 1,
tags: ["employee", "manager"]
}
I have this index:
{
"name": "embeddingIndexTags",
"definition": {
"mappings": {
"dynamic": True,
"fields": {
"embedding": {
"dimensions": 768,
"similarity": "cosine",
"type": "knnVector"
},
"tags": [{"type": "token",},
{"type": "string",}]
}
}
}
}
I want to filter the document based on tags.
Using LangChain
retriever=mongo_vectorstore.as_retriever(
search_kwargs = {"k": 4,
"pre_filter": {"tags":{"$in": ["employee"]},
},
}
)
For some reason, it is not working correctly.
I get results even if I put a tag that doesn’t exist like [“admin”].