It seems that "n/a" is tokenized internally into "n a" and therefore matching these letters
How to perform keyword search with Azure AI search
Hi,
I am able to successfully run vector and hybrid search on Azure AI Search following this example:
https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/search/azure-search-documents/samples/sample_vector_search.py
I would like to perform pure keyword search. For that I have added the following function to the code above:
def keyword_search():
# [START single_vector_search]
query = "n/a"
search_client = SearchClient(service_endpoint, index_name, AzureKeyCredential(key))
results = search_client.search(
search_text=query,
vector_queries=None,
select=["hotelId", "hotelName"],
)
for result in results:
print(result)
# [END single_vector_search]
The code runs and returns the following result:
{'hotelId': '2', 'hotelName': 'Roach Motel', '@search.score': 1.242726, '@search.reranker_score': None, '@search.highlights': None, '@search.captions': None}
But the query 'n/a' doesn't appear in the data and shouldn't match any result. The results variable should be empty.
In other words, how can I ensure that search() does match at least one keyword when it search_text is not None and vector_queries is None.
Thanks for your help.