Azure AI Search filter expression python vs query expression producing different results

Das Gupta, Abhijeet 105 Reputation points
2024-08-07T10:37:40.7933333+00:00

My aim is to retrieve filtered search docs based on values present in two different fields of Collection(Edm.String) type.

for example:

field1 = ['A', 'D']

field2 = ['B', 'C', 'E']

When I perform a search query in the azure portal UI using the following filter expression, I do not see the desired results which in this case should be zero documents but I do see some documents.

$filter = fieldA/any(a: a eq 'F') and fieldB/any(b: b eq 'C')

When I perform the same filter query on the search index using python SDK, I get zero retrieved docs which I is the desired result.

results = search_client.search(  
        search_text=query,  
        vector_queries= [vector_query],
        filter="fieldA/any(a: a eq 'F') and fieldB/any(b: b eq 'C')",
        select=["title_name", "chunk", "page_start"],
        top=6
    )

retrieved_docs = list()
for doc in results:
    retrieved_docs.append(doc)

>>> retrived_docs is []  

Can someone please explain what am I doing wrong in the $filter query? TIA

Azure AI Search
Azure AI Search
An Azure search service with built-in artificial intelligence capabilities that enrich information to help identify and explore relevant content at scale.
1,339 questions
0 comments No comments
{count} vote

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.