elasticsearch,Curl,elasticsearch" /> elasticsearch,Curl,elasticsearch" />

Curl 弹性搜索中的提升值

Curl 弹性搜索中的提升值,curl,elasticsearch,Curl,elasticsearch,我想在弹性搜索中搜索以下字符串时,为字段中的值设置一个boosting 索引值 id title 1. stack installer 2. stack 3. stack material 4. installer 我使用匹配查询搜索这些值,然后得到以下结果 查询: curl -XGET localhost:XXXX/index/type/_search?pretty -d '{"query":{"matchpharse": {"title":"stack installer"},

我想在弹性搜索中搜索以下字符串时,为字段中的值设置一个boosting

索引值

id title
1. stack installer
2. stack
3. stack material
4. installer
我使用匹配查询搜索这些值,然后得到以下结果

查询:

curl -XGET localhost:XXXX/index/type/_search?pretty -d '{"query":{"matchpharse":
     {"title":"stack installer"},
     "minimum_should_match":90
}'
stack installer
installer
stack material
stack
命中结果:

curl -XGET localhost:XXXX/index/type/_search?pretty -d '{"query":{"matchpharse":
     {"title":"stack installer"},
     "minimum_should_match":90
}'
stack installer
installer
stack material
stack
但是,我需要遵循输出的顺序

stack installer
stack
stack material
installer

在boolean-should语句中,您可以对should进行多个查询,并将某些查询提升到其他查询之上

curl -XGET localhost:XXXX/index/type/_search?pretty -d '{
  "query": {
    "bool": {
      "should": [
        {
          "match_phrase": {
            "title": "installer stack",
            "boost": 3
          }
        },
        {
          "match": {
            "title": "installer",
            "boost": 2
          }
        },
        {
          "match": {
            "title": "stack",
            "boost": 1
          }
        }
      ]
    }
  }
}'

它的工作很好…如果我的输入是“堆栈安装程序控制器”。。我可以在固定查询中获得结果,不需要频繁更改查询..如果我搜索stack over flow或stack over flow installer,@Kumar asking,只需一次查询即可获得该结果。。如何将Boost值设置为“Stack”term..对于要增加优先级的每个term,您需要单独为该term添加不同的匹配查询。将其余的放在匹配查询中。我在匹配查询中设置了boost属性,它将不起作用