I am using Azure Search AI service to store my documents chunk along with some information inside the metadata. However when I try to filter on metadata the filter does not work.
Here is an example of the document object:
Document(metadata={'id': 'MzRiZDk5ZWMtNzkyNy00YzdlLTgzMjctMGQyNzA2NzRiNjQ4', 'FileName': 'Document_X', 'Directory': 'Directory_X'}, page_content='this is the document about...'})
So what I do when I want to initialize the retriever to retrieve the filtered chunk
retriever = azure_search_db.as_retriever(filter = "FileName eq 'Document_X'")
Then I run invoke method to get the most similar chunk based on a specific query:
retriever.invoke("wifi example")
However I don’t have the chunk filtered.
What is wrong with the parameter “filters” inside the as_retriever
method?
Are you using the library https://pypi.org/project/azure-search-documents/?
This is the official Azure AI Search Python SDK but there is no as_retriever method.
(I am a Microsoft employee working in the Azure SDK team.)