I am looking for a way to retrieve the search score in the search result (an index field value), similar to the other metadata fields like metadata_storage_name or metadata_storage_path. In the Indexer Definition, I tried retrieving the search score in the following way. Please correct me if I am missing anything or retrieving it the wrong way.
"fieldMappings": [
{
"sourceFieldName": "@search.score",
"targetFieldName": "search_score",
"mappingFunction": null
}
]
CodePudding user response:
Search score is an attribute added to each search result in the search request response. Try issue a simple search request using your favourite REST client or Azure Poral. Below is an example of a response object. @search.score is what you're looking for.
"value": [
{
"@search.score": 7.3617697,
"HotelId": "21",
"HotelName": "Nova Hotel & Spa",
"Description": "1 Mile from the airport. Free WiFi, Outdoor Pool, Complimentary Airport Shuttle, 6 miles from the beach & 10 miles from downtown.",
"Category": "Resort and Spa",
"Tags": [
"pool",
"continental breakfast",
"free parking"
]
},
{
"@search.score": 2.5560288,
"HotelId": "25",
"HotelName": "Scottish Inn",
"Description": "Newly Redesigned Rooms & airport shuttle. Minutes from the airport, enjoy lakeside amenities, a resort-style pool & stylish new guestrooms with Internet TVs.",
"Category": "Luxury",
"Tags": [
"24-hour front desk service",
"continental breakfast",
"free wifi"
]
}]
Example is from here: https://docs.microsoft.com/en-us/azure/search/search-query-simple-examples#example-1-full-text-search
CodePudding user response:
'@search.score' is not a field in an index, but a computation of each search result relevance scoring. If there is a match for the criteria of your search and a result returned, you can retrieve that value from the HTTP response with '@search.score'.
Field mappings on the other hand are used to map a field that is found in your data source and does not match the name you would like to use in the index, so you can map to the name you need.
For more information on the HTTP response of Search Documents REST API and search scoring, please visit: https://docs.microsoft.com/rest/api/searchservice/search-documents and https://docs.microsoft.com/azure/search/index-similarity-and-scoring