# Or terms query

**URL:** <https://discuss.elastic.co/t/or-terms-query/133747>\
**Category:** Elasticsearch\
**Created:** [May 29, 2018, 7:56pm UTC](https://discuss.elastic.co/t/or-terms-query/133747 "2018-05-29T19:56:02Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Illidan](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/illidan/32/54264_2.png) [@Illidan](https://discuss.elastic.co/u/Illidan)\
**Post date:** [May 29, 2018, 7:56pm UTC](https://discuss.elastic.co/t/or-terms-query/133747/1 "2018-05-29T19:56:02Z")

</div>

I'm using NEST to build a dynamic query. I trying to do something like:

> "Get results having property 'DateDeleted' in date range {A} **or** in date range {B}."

I was trying different approaches but something is wrong is I getting wrong results..

This is what I was trying to do:

```
                 var queryDescriptor = new QueryContainerDescriptor<JobDocument>();

                  queryContainer &= (queryDescriptor.DateRange(a => a
                        .Field(f => f.DateDeleted)
                        .GreaterThan(sampleDate)) |

                        queryDescriptor.DateRange(a => a
                        .Field(f => f.DateDeleted)
                        .LessThan(new DateTime(1980, 1, 1))));

```

How I can combine two 'DateRange' queries using "OR" condition?

---

<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:** [June 26, 2018, 7:56pm UTC](https://discuss.elastic.co/t/or-terms-query/133747/2 "2018-06-26T19:56:04Z")

</div>

Closed on June 26, 2018, 7:56pm UTC

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