我正在使用 Azure 搜索索引来创建产品的分面搜索。我有大约 5 个方面来帮助过滤显示的产品列表。
我注意到的一件事是,如果列出了相当多的产品以使用构面进行过滤,则属于构面内的较小搜索项不会从索引中返回。
例如(简单来说),如果我的索引在某个方面列出了以下汽车制造商:
- 奥迪 (312)
- 宝马 (203)
- 沃尔沃 (198)
- 斯柯达(4)
我发现斯柯达不会被返回,因为链接到该制造商的搜索结果很少。
当我使用以下查询直接在 Azure 门户中搜索索引时,我可以看到这种情况:facet=<facet-field-name>
经过一番研究,我发现了以下内容 explanation :
Facet counts can be inaccurate due to the sharding architecture. Every search index has multiple shards, and each shard reports the top N facets by document count, which is then combined into a single result. If some shards have many matching values, while others have fewer, you may find that some facet values are missing or under-counted in the results.
Although this behavior could change at any time, if you encounter this behavior today, you can work around it by artificially inflating the count: to a large number to enforce full reporting from each shard. If the value of count: is greater than or equal to the number of unique values in the field, you are guaranteed accurate results. However, when document counts are high, there is a performance penalty, so use this option judiciously.
根据上面的引用,我如何人为地增加计数来解决这个问题?或者有人知道更好的方法吗?
最佳答案
默认构面计数为 10。您可以使用 count
参数作为构面表达式的一部分来指定更大的计数。例如,假设您使用带有 HTTP GET 请求的 REST API:
facet=myfield,count:100
如果您使用的是 .NET SDK:
var parameters =
new SearchParameters()
{
Facets = new[] { "myfield,count:100" }
};
var results = indexClient.Documents.Search("*", parameters);
您可以在 Azure Search REST API Reference 中找到有关构面表达式语法的更多详细信息。 .
关于c# - Azure 搜索 - 较小的方面计数未从索引返回,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47500715/