Azure 搜索 - 来自逗号分隔值字符串的匹配值

Azure Search - Match value from comma-separated values string

如何构建 Azure POST REST 调用以匹配逗号分隔列表字符串中的值?

例如:
我想在 Azure 字段 "ProductCategory" 中搜索 "GWLAS" 或 "SAMGV"。

文档中的 "ProductCategory" 字段将有一个逗号分隔的值字符串,例如 "GWLAS, EXDEB, SAMGV, AMLKYC"。


有什么想法吗?

如果您对 ProductCategory 字段使用默认分析器(假设它是可搜索的),默认情况下它应该在逗号上进行分词。这意味着您需要做的就是搜索您感兴趣的术语并将其限制在正确的字段中:

POST /indexes/yourindex/docs/search?api-version=2016-09-01

{
    "search": "GWLAS SAMGV",
    "searchFields": [ "ProductCategory" ]
}

还有其他方法可以做到这一点,但这是最简单的。如果您已经将部分搜索查询范围限定到其他字段,可以按照以下方法将所需的字词限定到 ProductCategory:

POST /indexes/yourindex/docs/search?api-version=2016-09-01

{
    "search": "(Name:\"Anderson John\"~3 OR Text:\"Anderson John\"~3) AND ProductCategory:GWLAS SAMGV",
    "queryType": "full"
}

请参考Azure Search REST API documentation for details on other options you can set in the Search request. Also, this article will help you understand how Azure Search executes queries. You can find the reference for the full Lucene query syntax here