gpt4 book ai didi

elasticsearch - Elasticsearch 文档提升(如Solr elevateIds)

转载 作者:行者123 更新时间:2023-12-02 22:25:30 24 4
gpt4 key购买 nike

由于其亚马逊REST API和适用于集群,因此希望从Solr转向Elastic Search。但是,我正在努力想出一种在查询时增强特定文档的方法,例如Solrs elevate方法。有没有一种方法可以做到这一点,如果有的话,任何例子都将非常有用:)

最佳答案

我假设您正在引用Solr QueryElevationComponent。 https://wiki.apache.org/solr/QueryElevationComponent

之前在github上已有关于如何在Elasticsearch中模拟此功能的讨论。 https://github.com/elasticsearch/elasticsearch/issues/1066

这个想法是使用Elasticsearch常数得分查询来为匹配文档应用常数提升。施加足够大的提升,实际上可以得到Solr's Elevate的“赞助搜索”结果。

从文档中:

Constant Score Query

A query that wraps a filter or another query and simply returns a constant score equal to the query boost for every document in the filter. Maps to Lucene ConstantScoreQuery.

{
"constant_score" : {
"filter" : {
"term" : { "user" : "kimchy"}
},
"boost" : 1.2
}
}

The filter object can hold only filter elements, not queries. Filters can be much faster compared to queries since they don’t perform any scoring, especially when they are cached.

A query can also be wrapped in a constant_score query:

{
"constant_score" : {
"query" : {
"term" : { "user" : "kimchy"}
},
"boost" : 1.2
}
}


http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/query-dsl-constant-score-query.html

编辑

使用多次提升的示例:
{
"query": {
"bool": {
"should": [{
"constant_score": {
"filter": {
"terms": {
"user": ["kimchy", "john"]
}
},
boost: 3
}
}, {
"constant_score": {
"filter": {
"terms": {
"user": ["paul", "ringo"]
}
},
boost: 2
}
}]
}
}
}

关于elasticsearch - Elasticsearch 文档提升(如Solr elevateIds),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24457266/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com