Elasticsearch match by either of two fields

Viewed 47

Similar to elasticsearch match two fields, I would like to execute a query in ES that uses OR operator

SELECT * FROM [mytype] WHERE title = 'some title' OR title = 'something else'
1 Answers

You can use bool/should clause

{
  "query":{
    "bool":{
      "should":[
        {
          "match":{
            "title":"some title"
          }
        },
         {
          "match":{
            "title":"something else"
          }
        }
      ]
    }
  }
}
Related