跨分片的 IDF 相似性未按预期工作,仅使用本地分片信息

IDF similarity across shards does not work as expected, uses only local shard info

我正在为我的杂货产品数据使用 solr(7.3)。由于 idf 跨多个分片(3 个分片)的数据,我发现了奇怪的结果。

我的搜索关键字是 "milk"

牛奶在我的 collection 中并不是真正罕见的关键字。但是,在其中一个分片中,只有很少的文档(9000 个文档中有 1-2 个文档)包含关键字 milk。所以在那个分片(shard1)中,idf 得分非常高,几乎是其他分片得分的 3 倍。这影响了我的结果。我不希望来自 shard1 的特定文档成为最佳结果。

有什么方法可以控制 idf 评分,就像我们可以使用 k1 和 b 参数在 BM25 中对 tf 做的那样?

或者我们有没有 idf 相似度的 BM25?我可以创建自己的相似性并使用它,但我们的 solr 服务不允许自定义 solr。

或者有其他方法可以解决这个问题吗?

您可以使用 different statsCache to get support for distributed IDF。默认选项 (localStatsCache) 仅使用本地分片中的值,但您可以将其更改为分布式选项之一,以使 Solr 在计算分数时使用集合范围的 idf。

Document and term statistics are needed in order to calculate relevancy. Solr provides four implementations out of the box when it comes to document stats calculation:

LocalStatsCache: This only uses local term and document statistics to compute relevance. In cases with uniform term distribution across shards, this works reasonably well. This option is the default if no is configured.

ExactStatsCache: This implementation uses global values (across the collection) for document frequency.

ExactSharedStatsCache: This is exactly like the exact stats cache in its functionality but the global stats are reused for subsequent requests with the same terms.

LRUStatsCache: This implementation uses an LRU cache to hold global stats, which are shared between requests.

The implementation can be selected by setting in solrconfig.xml. For example, the following line makes Solr use the ExactStatsCache implementation:

<statsCache class="org.apache.solr.search.stats.ExactStatsCache"/>