A
A
atis //2017-07-13 20:14:25
elasticsearch
atis //, 2017-07-13 20:14:25

OR query for Elasticsearch?

How can I make a query similar to SQL for ElasticSearch?

SELECT * FROM table WHERE ( field = 1 && field2 = 2) || (field3 = 3)

type
{
  "query": {
    "bool": {
       "must": [
          {"term": {"field": {"value": 1}}},
          {"term": {"field2": {"value": 2}}},
         // OR
          {"term": {"field3": {"value": 3}}}
        ]
     }
  }
}

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
RidgeA, 2017-07-13
@RidgeA

Something like that, but now there is nothing to check on

{
  "query": {
    "bool": {
       "should": [
          {
            "bool" : {
                           "must" : [
                                            {"term": {"field": {"value": 1}}},
                                            {"term": {"field2": {"value": 2}}},
                                        ]   
                        }
           },
          {"term": {"field3": {"value": 3}}}
        ]
     }
  }
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question