问题描述
我想根据查询的数量接近得分我的文档。鉴于我有两个文件 document1.field = 1
和 document2.field = 10
,查询 field = 3
然后我想要 document1._score> document2._score
。或者换句话说,我想要一个像模糊查询的数字。我该如何实现?用例是我想支持价格查询(精确或范围),但是要排序不完全在边界的内容。
I want to score my documents based on on how close a number is to a query. Given I have two documents document1.field = 1
and document2.field = 10
, a query field = 3
then I want document1._score > document2._score
. Or in other words I want something like a fuzzy query against number. How would I achieve this? The use case is I want to support price queries (exact or range), but want to rank stuff that isn't exactly in the boundaries.
推荐答案
可以使用查询。这里的过滤器将包含所需价格的不同范围。较小的范围将有较高的提升,并在列表中显示较高的范围。
Alternatively, it can be implemented using custom_filters_score query. Filters here will contain different ranges around desired price. Smaller ranges will have higher boost and appear higher in the list than larger ranges.
这篇关于基于数字与查询的接近程度进行弹性搜索评分的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!