Azure 认知搜索 - 在搜索结果中检索搜索分数

Posted

技术标签:

【中文标题】Azure 认知搜索 - 在搜索结果中检索搜索分数【英文标题】:Azure Cognitive Search - Retrieve Search Score in Search Result 【发布时间】:2022-01-24 07:02:05 【问题描述】:

我正在寻找一种方法来检索搜索结果中的搜索分数(索引字段值),类似于 metadata_storage_name 或 metadata_storage_path 等其他元数据字段。在索引器定义中,我尝试通过以下方式检索搜索分数。如果我遗漏任何内容或以错误的方式检索它,请纠正我。

  "fieldMappings": [    
    
      "sourceFieldName": "@search.score",
      "targetFieldName": "search_score",
      "mappingFunction": null
    
  ]

【问题讨论】:

【参考方案1】:

搜索分数是添加到搜索请求响应中每个搜索结果的属性。尝试使用您最喜欢的 REST 客户端或 Azure Poral 发出一个简单的搜索请求。下面是响应对象的示例。 @search.score 就是您要查找的内容。

"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"
    ]
]

示例来自这里:https://docs.microsoft.com/en-us/azure/search/search-query-simple-examples#example-1-full-text-search

【讨论】:

【参考方案2】:

'@search.score' 不是索引中的字段,而是每个搜索结果相关性评分的计算。如果您的搜索条件匹配并返回结果,您可以使用“@search.score”从 HTTP 响应中检索该值。

另一方面,字段映射用于映射在数据源中找到且与您希望在索引中使用的名称不匹配的字段,因此您可以映射到您需要的名称。

有关 Search Documents REST API 的 HTTP 响应和搜索评分的更多信息,请访问: https://docs.microsoft.com/rest/api/searchservice/search-documents 和 https://docs.microsoft.com/azure/search/index-similarity-and-scoring

【讨论】:

以上是关于Azure 认知搜索 - 在搜索结果中检索搜索分数的主要内容,如果未能解决你的问题,请参考以下文章

Azure 认知搜索和 Cosmos DB RU 消耗

有没有办法在使用 Azure 认知搜索服务升序排序时忽略空值?

有没有办法确定 Azure 认知搜索中的索引器索引了哪些文件?

Azure搜索数据检索

从 asp.net mvc 网站到 azure 认知搜索的连接问题

使用 Azure 存储容器元数据作为搜索筛选器