# And/OR DSL Query

**URL:** <https://discuss.elastic.co/t/and-or-dsl-query/300985>\
**Category:** Elasticsearch\
**Created:** [March 29, 2022, 2:56pm UTC](https://discuss.elastic.co/t/and-or-dsl-query/300985 "2022-03-29T14:56:07Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![JeremyP](https://avatars.discourse-cdn.com/v4/letter/j/43a26b/32.png) [@JeremyP](https://discuss.elastic.co/u/JeremyP)\
**Post date:** [March 29, 2022, 2:56pm UTC](https://discuss.elastic.co/t/and-or-dsl-query/300985/1 "2022-03-29T14:56:08Z")

</div>

Hello,

I'm having a difficult time getting a DSL query to work right with a combination of an AND and OR.

For the OR side, one of the two must be present in the document....

{ "state": "active" }  
{ "state": "re-surfaced" }

And all documents must be present in the following date range.....

"range":  
{  
"last\_assessed\_for\_vulnerabilities": {  
"gte": "now-75d/d",  
"lte": "now-45d/d"  
}

So logic is as follows:

(state=active or state=re-surfaced) and (range)

I have this so far, but I'm running into syntax issues.

```auto
  "query": 
  {
    "bool": 
    {
      "must": 
      [ 
        {
          "bool": 
          {
            "should": 
            [
              { "match": { "state": "active" } },
              { "match": { "state": "re-surfaced" } }
            ]
          },
           "range": 
           {
             "last_assessed_for_vulnerabilities": {
               "gte": "now-75d/d",
               "lte": "now-45d/d"
             }
           }
        }
      ]  
    }
  }
}

```

Any help would be appreciated!

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [April 26, 2022, 2:56pm UTC](https://discuss.elastic.co/t/and-or-dsl-query/300985/2 "2022-04-26T14:56:26Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
