在弹性搜索中优先搜索结果

时间:2019-10-24 09:53:25

标签: python python-3.x elasticsearch

我有一个多索引多字段搜索查询,我需要对查询结果进行优先级排序,即我有一个优先级列表,并且如果查询返回的结果存在于优先级列表中,则我希望弹性-搜索以使他们得分更高。

当前,我正在ES返回结果之后执行此操作。我遍历整个列表,如果存在匹配的结果,则将它们放在其部分的前面。有没有一种方法可以直接在ES中实现?

技术堆栈:

Python 3.5
ElasticSearch 6.6.0

供参考: nd-json中的ES查询。

{"index": "countries"}
{"min_score": 20.0, "size": 5, "query": {"multi_match": {"fuzziness": "AUTO", "fields": ["name^2", "region"], "query": "new york", "operator": "and"}}}
{"index": "cities"}
{"min_score": 20.0, "size": 10, "sort": [{"_geo_distance": {"geo_location": {"lat": 40.7128, "lon": -74.2708}, "unit": "km"}}, "_score"], "query": {"multi_match": {"fuzziness": "AUTO", "fields": ["name^2", "state", "country"], "query": "new york", "operator": "and"}}}

0 个答案:

没有答案