ElasticSearch, multi-match with filter?

后端 未结 4 383
情深已故
情深已故 2021-01-30 08:30

I have a multi-match query in ES, and wish to add a filter.

{
  \"multi_match\" : {
    \"query\" : \"this is a test\",
    \"fields\" : [ \"subject^2\", \"messa         


        
4条回答
  •  粉色の甜心
    2021-01-30 09:23

    With Elasticsearch 5 the syntax has changed to the usage of bool query, e.g.

    {
      "from" : 0,
      "size" : 10,
      "sort" : "publishDate",
      "query": {
        "bool": {  
          "must" : {
            "multi_match" : {
              "query":      "wedding",
              "type":       "most_fields",
              "fields":     [ "title", "text" ]
            }
          },
          "filter": {
            "term": {
              "locale": "english"
            }
          }
        }
      }
    }
    

    Documentation can be found here.

提交回复
热议问题