# Multiple Filter NEST Query DSL

**URL:** <https://discuss.elastic.co/t/multiple-filter-nest-query-dsl/121835>\
**Category:** Elasticsearch\
**Created:** [February 28, 2018, 10:58am UTC](https://discuss.elastic.co/t/multiple-filter-nest-query-dsl/121835 "2018-02-28T10:58:39Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![DiSiZ](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/disiz/32/60095_2.png) [@DiSiZ](https://discuss.elastic.co/u/DiSiZ)\
**Post date:** [February 28, 2018, 10:58am UTC](https://discuss.elastic.co/t/multiple-filter-nest-query-dsl/121835/1 "2018-02-28T10:58:39Z")

</div>

Is this possible to have multiple BoudingBox for one geoboundingbox ?

---

<div class="post-metadata">

**Author:** ![DiSiZ](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/disiz/32/60095_2.png) [@DiSiZ](https://discuss.elastic.co/u/DiSiZ)\
**Post date:** [February 28, 2018, 1:30pm UTC](https://discuss.elastic.co/t/multiple-filter-nest-query-dsl/121835/2 "2018-02-28T13:30:09Z")

</div>

Let me add some details, right now i have this kind of request:

```
BOOL
| _____ MUST
--------| ______ TERM1
--------|
--------|FILTER
--------| _______ TERM1
--------| _______ TERM2
--------| _______ TERM3
--------| _______ TERM4

```

I'd like to have this scheme :

```
BOOL
| _____ MUST
--------| ______ TERM1
--------|
--------|AND
--------|
--------|FILTER
--------| _______ TERM1
--------| _______ TERM2
--------| _______ TERM3
--------| _______ TERM4
--------|
--------| OR
--------|
--------|FILTERx
--------| _______ TERM1x
--------| _______ TERM2x
--------| _______ TERM3x
--------| _______ TERM4x

```

1 filter is equivalent to 1 boudingbox request.  
The problem is, he always take the last filter written as condition.

Using Query DSL here's my code request:

```
            var searchResponse = client.LowLevel.Search<StringResponse>("jam", "jam", PostData.Serializable(new SearchDescriptor<Source>()
               .From(0)
               .Size(size)
               .Query(q => q
                   .Bool(b => b
                       .Must(fi => fi
                           .DateRange(r => r
                               .Field(f => f.Timestamp)
                               .GreaterThanOrEquals(limitDate)
                               .LessThan(DateTime.Now)
                           ), mu => mu
                       )
                   
                       .Filter(mu => mu
                           .GeoBoundingBox(ge => ge
                               .Field(f => f.End)
                               .BoundingBox(latLeft2, lonLeft2, latRight2, lonRight2)
                           ) || q
                           .GeoBoundingBox(ge => ge
                               .Field(f => f.Start)
                               .BoundingBox(latLeft2, lonLeft2, latRight2, lonRight2)
                           )
                       )
                       .Filter(mu => mu
                           .GeoBoundingBox(ge => ge
                               .Field(f => f.End)
                               .BoundingBox(latLeft, lonLeft, latRight, lonRight)
                           ) || q
                           .GeoBoundingBox(ge => ge
                               .Field(f => f.Start)
                               .BoundingBox(latLeft, lonLeft, latRight, lonRight)
                           )
                       )

                   )
               )
           ));

```

In this case he always choose the seconde filter, which is logic, im trying some tricks to change that, as a beginner on [Elastic.NET](http://Elastic.NET) its pretty hard

Found it :

```
                     .Filter(
                        mu => mu.GeoBoundingBox(ge => ge
                             .Field(f => f.End)
                             .BoundingBox(latLeft, lonLeft, latRight, lonRight)
                         ) || q
                         .GeoBoundingBox(ge => ge
                             .Field(f => f.Start)
                             .BoundingBox(latLeft, lonLeft, latRight, lonRight)
                         ) || q
                         .GeoBoundingBox(ge => ge
                             .Field(f => f.End)
                             .BoundingBox(latLeft2, lonLeft2, latRight2, lonRight2)
                         ) || q
                         .GeoBoundingBox(ge => ge
                             .Field(f => f.Start)
                             .BoundingBox(latLeft2, lonLeft2, latRight2, lonRight2)
                         )
                     )
```

---

<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:** [March 28, 2018, 1:44pm UTC](https://discuss.elastic.co/t/multiple-filter-nest-query-dsl/121835/3 "2018-03-28T13:44:59Z")

</div>

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