Kshtiiz Gupta
Kshtiiz Gupta

Reputation: 11

Elastic Search- Search with multiple values with an or condition

I have following kind of data indexed into Elastic Search(ES). { "name":"XYZ", "categoryTags":["ABC","DEF","GHI", "IJK"....] }

I want to search all documents which have say categoryTags(atleast one of them or more) : "ABC" or "GHI" or "IJK" Can anyone suggest me a query for this use case?

Thanks in Advance

Upvotes: 0

Views: 418

Answers (2)

Prabin Meitei
Prabin Meitei

Reputation: 2000

You can make use of Term Filter or the Term Query. You can pass the query body as post parameter. Details can be easily found in ES docs.

  {
     "filter" : {
        "terms" : {
            "categoryTags" : ["ABC", "GHI", ...]
        }
      }
   }

   or 

   {
      "query" : {
           "term" : {"categoryTags" : ["ABC", "GHI", ...]}
      }
   }

Refer to ES documents.

Upvotes: 1

BasK
BasK

Reputation: 292

Copy and paste below command at your webbrowser.

http://xx.xx.xx.xx:9200/index_v1/type/_search?q=categorytag:abc|ghi&size=50

i hope this is very useful to u .

Upvotes: 0

Related Questions