How to match multiple words via terms in elasticsearch How to match multiple words via terms in elasticsearch elasticsearch elasticsearch

How to match multiple words via terms in elasticsearch


Based on your comment on the above answer, I believe you should simply use two term queries inside your must query array.

{  "query":     { "bool" :          {             "must":[                        {"term":{"my_field": "word1" } },                        {"term":{"my_field": "word2" } }                    ]           }     }  } 


you can try to put the words in an array and see if it works. Like this: {"query": {"bool":{"must":[{"terms":{"my_field":["word1", "word2"]}}]}

here is the documentation: https://www.elastic.co/guide/en/elasticsearch/guide/current/_finding_multiple_exact_values.html

Hope it works =)