As implied by this article: https://techcommunity.microsoft.com/t5/ai-azure-ai-services-blog/azure-cognitive-search-outperforming-vector-search-with-hybrid/ba-p/3929167 it is possible to perform a hybrid search with semantic re-ranking over the result set. However, I have been unable to implement these together in the python SDK. If parameters for both are set, semantic will take precedence.
The code snippet below works, but as mentioned, this will only perform a semantic search (i.e. will return the same search results if I remove vector_queries
from client.search()
. Similarly, removing query_type
, semanic_configuration_name
, and query_answer
allows me to perform a hybrid search. However, I want to perform both.
vector = embedding_client.embeddings.create(input = [name], model="embedding").data[0].embedding
vector_query = VectorizedQuery(vector=vector,k_nearest_neighbors=4,fields="contentVector")
credential = AzureKeyCredential(key)
client = SearchClient(endpoint=service_endpoint,
index_name=index_name,
credential=credential)
results = client.search(search_text=name,
vector_queries=[vector_query],
query_type="semantic",
semantic_configuration_name = "azureml-default",
query_answer="extractive",
top = 4
)
Does such functionality exist in the SDK? I have attached a screenshot of the implementation using the REST api.
REST api implementation