简体   繁体   English

Elasticsearch多个术语可以促进

[英]Elasticsearch Multiple Terms to Boost

i've been trying to find the right format for a mutliple boost query for the last hour, could someone assist me in writing this correctly? 我一直在努力为过去一个小时的多重查询查找正确的格式,有人可以帮助我正确地编写此格式吗? essentially it is a single query that can do the below many times. 本质上,它是一个可以多次执行以下操作的查询。

This Works: 这有效:

{
    "query": {
        "match" : {
            "title": {
                "query": "brain",
                "boost": 2
            }
        }
    }
}

This is what i am trying to achieve but does not work. 这是我想要达到的目标,但是没有用。 One normal term to search in title and two other boosted terms to also prioritise in title. 在标题中搜索一个正常术语,在标题中优先搜索另外两个术语。

{
    "query": {
        "match" : {
           "title": {
                "query": "neuron",
            },
            "title": {
                "query": "brain",
                "boost": 2
            },
                "query": "birdsong",
                "boost": 3
            }
        }
    }
}

Another thing i'd like to clarify is: 我想澄清的另一件事是:

In order for ElasticSearch to understand queries like the above from a web application they must be submitted as a Post HTTP request? 为了使ElasticSearch能够从Web应用程序理解上述查询,它们是否必须作为Post HTTP请求提交?

You need to issue a bool/should query like this: 您需要发出bool/should查询:

POST index/_search
{
  "query": {
    "bool": {
      "should": [
        {
          "match": {
            "title": {
              "query": "neuron"
            }
          }
        },
        {
          "match": {
            "title": {
              "query": "brain",
              "boost": 2
            }
          }
        },
        {
          "match": {
            "title": {
              "query": "birdsong",
              "boost": 3
            }
          }
        }
      ]
    }
  }
}

Both GET and POST are accepted when sending a query. 发送查询时,GET和POST均被接受。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM