ElasticSearch filtered bool query not working with multi_match

1k Views Asked by At

I have this installed on Ubuntu running ElasticSearch 6.2.3

I am new to ES so if this is duplicate or obvious I am sorry.

I just need to do a contains query that filters out items not marked as PUBLISHED.

Here is what i think should be returning the correct results but it returns nothing (0 hits):

GET /index/type/_search
{
  "query": {
    "bool" : {
      "must" : {
        "multi_match" : {
          "query": "Funny black cat",
          "operator": "and",
          "fields": [ "title", "description"]
        }
      },
      "filter": {
        "term" : { "publishStatus" : "PUBLISHED" }
      }
    }
  }
}

Furthermore, this simple filter query is also return 0 records...

GET /index/type/_search
{
  "query": {
    "bool": {
      "filter": {
        "term": {
          "publishStatus": "PUBLISHED"
        }
      }
    }
  }
}
1

There are 1 best solutions below

0
On

Well this is what worked for me (stopped using filter, changed to match):

GET index/type/_search
{
  "query": {
    "bool":{
      "must":[ 
        {
          "multi_match" : {
            "query":    "dinner sydney", 
            "fields": [ "title^3", "description" ],
            "operator":   "and"
          }
        },{
          "match": { "publishStatus": "PUBLISHED"}
        }
      ]
    }
  }
}