venkat
venkat

Reputation: 73

Query for OR condition

I need elasticsearch query for following sql

SELECT document FROM  brand WHERE  brandprivacy=false or (brandid=['1','3'])

Upvotes: 0

Views: 45

Answers (1)

Val
Val

Reputation: 217554

You can achieve it with this query:

POST brand/_search
{
  "_source": ["document"],
  "query": {
    "bool": {
      "minimum_should_match": 1,
      "should": [
        {
          "term": {
            "brandprivacy": false
          }
        },
        {
          "terms": {
            "brandid": [
              "1",
              "3"
            ]
          }
        }
      ]
    }
  }
}

I also suggest that you should take the time to go through the Query DSL guide and learn the different queries that ES supports.

Upvotes: 1

Related Questions