Search code examples
elasticsearchelasticsearch-6

Elasticsearch 6.2 search by array each item


I have array set like this,

"title": "Living furniture exhibitions!"
"include_products": ["ikea chair", "marketO desk"]

And I try to search like this.

{
    "query": {
      "multi_match": {
        "query": "ikea desk",
        "operator": "and"
      }
    }
}

I do not want any search result. But, It searched by ["ikea chair", "marketO desk"].

How can I search each item in include_products array?

Also, my mapping setting like this,

"mappings": {
    "information" : {
      "properties" : {
        "title" : {
          "type" : "text"
        },
        "include_products": {
          "type": "text"
        }
      },
      "_all": {
        "enabled": false
      }
    }
 }

Solution

  • try with this

    {
          "query":{
              "bool":{
                  "must":[
                      {
                          "match_phrase":{
                              "include_products":"ikea desk"
                          }
                      }    
                  ]
              }
          }
        }