Thursday, May 4, 2023

How to Include @search.score in Azure Cognitive Search Suggest Response

 You can return the search score (@search.score) in the response along with the suggested search terms using Azure Cognitive Search Suggest API. Here's how you can do it:

  1. In the suggest query, add "@search.score" to the "select" parameter to include the search score in the response.

For example:

https://[service name].search.windows.net/indexes/[index name]/docs/suggest?api-version=[api-version]&suggesterName=[suggester name]&search=[user input]&$select=searchText,@search.score

  1. In the Suggester definition, add "@search.score" to the "sourceFields" parameter to enable scoring of the suggested search terms.

For example:

{ "name": "[suggester name]", "searchMode": "analyzingInfixMatching", "sourceFields": ["[field name 1]", "[field name 2]", "@search.score"] }


No comments:

Post a Comment

ASP.NET Core

 Certainly! Here are 10 advanced .NET Core interview questions covering various topics: 1. **ASP.NET Core Middleware Pipeline**: Explain the...