I am recently using elasticsearch in a website. The scenario is, I have to search a string on afield. So, if the field is named as title then my search query was,
"query" :{"match": {"title": my_query_string}}.
But now I need to add another field in it. Let say, category. So i need to find the matches of my string which are in category :some_category and which have title : my_query_string I tried with multi_match. But it does not give me the result i am looking for. I am looking into query filter now. But is there way of adding two fields in such criteria in my match query? 
GET indice/_search
{
  "query": {
    "bool": {
      "should": [
        {
          "match": {
            "title": "title"
          }
        },
        {
          "match": {
            "category": "category"
          }
        }
      ]
    }
  }
}
Replace should with must if desired.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With