【问题标题】:How to do faceted search with Azure cognitive search?如何使用 Azure 认知搜索进行分面搜索?
【发布时间】:2020-10-01 03:17:19
【问题描述】:

我正在尝试在 Azure 认知搜索中进行分面搜索。我正在使用邮递员(和 curl)进行测试。

有一个字段state_name 是可分面的。在https://docs.microsoft.com/en-us/rest/api/searchservice/search-documents 之后,如果我将 POST 请求有效负载发送为:

{
    "facets": "state_name"
}

它返回此错误:

{
    "error": {
        "code": "",
        "message": "The request is invalid. Details: parameters : When trying to read a null collection parameter value in JSON Light, a node of type 'PrimitiveValue' with the value 'state_name' was read from the JSON reader; however, a primitive 'null' value was expected.\r\n"
    }
}

进行构面搜索的正确方法是什么?


更新:

payload中的facets应该是一个数组:

{
    "facets": ["state_name"]
}

https://docs.microsoft.com/en-us/rest/api/searchservice/search-documents#bkmk_examples所示

【问题讨论】:

    标签: azure curl postman azure-cognitive-search


    【解决方案1】:

    您需要将 facet 字段指定为 url 的一部分:

    GET /indexes/hotels/docs?search=*&facet=state_name&api-version=2019-05-06

    更多信息:https://docs.microsoft.com/en-us/rest/api/searchservice/search-documents#bkmk_examples

    【讨论】:

      猜你喜欢
      • 2021-05-12
      • 2020-10-15
      • 2022-01-24
      • 2021-11-21
      • 2020-03-27
      • 1970-01-01
      • 2014-11-29
      • 1970-01-01
      • 2021-10-18
      相关资源
      最近更新 更多