I’m trying to use semantic search enabled azure cognitive search in my flask app (in python virtual env).
When I do pip install azure.search.documents, 11.3.0 version gets installed
and I get following error:
TypeError: Session.request() got an unexpected keyword argument 'query_language'
same for query_speller, semantic_configuration_name etc.
here is the code I’m using:
results = list(
self.search_client.search(search_text="xxx",
query_type ="semantic",
query_language ="en-us",
query_speller ="lexicon",
semantic_configuration_name ="xxx",
top=3,
captions= None)
below code works fine
results = list(self.search_client.search(search_text="xxx"))
2
Answers
Semantic search is still in preview and only available in beta versions.
Please try install latest beta version of azure-search-documents library.
(I work in the SDK team in MS)
I tried in my environment and got the below results:
Initially, I got the same error that occurs when I try with
azure-search-documents=11.3.0
package in my environment.You can use the below code and package to get the semantic search enabled Azure cognitive search.
Package:
Code:
Output:
The above code was executed and successfully get the required results.
Also, make sure your Semantic search is enabled for your service.
Reference:
Azure.search.documents.SearchClient class | Microsoft Learn