# DateRangeQuery with NEST results with server error 400 - "all shards failed"

**URL:** <https://discuss.elastic.co/t/daterangequery-with-nest-results-with-server-error-400-all-shards-failed/261059>\
**Category:** Elasticsearch\
**Tags:** language-clients\
**Created:** [January 13, 2021, 9:47pm UTC](https://discuss.elastic.co/t/daterangequery-with-nest-results-with-server-error-400-all-shards-failed/261059 "2021-01-13T21:47:46Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Izzy](https://avatars.discourse-cdn.com/v4/letter/i/c2a13f/32.png) [@Izzy](https://discuss.elastic.co/u/Izzy)\
**Post date:** [January 13, 2021, 9:47pm UTC](https://discuss.elastic.co/t/daterangequery-with-nest-results-with-server-error-400-all-shards-failed/261059/1 "2021-01-13T21:47:46Z")

</div>

I'm using NEST client on my .NET Core 3.1 (C#) application.  
I'm trying to write a search query by using QueryContainer.  
So far, search is working fine with textual fields, but when I'm trying to search according to DateRangeQuery I'm getting this server error 400 "all shards failed".  
Here is a sample of my code:

```auto
    List<QueryContainer> queriesList;
    QueryContainer queryContainer = new QueryContainer(new DateRangeQuery() { Field = GetCamelCaseString(this._currentKey), GreaterThanOrEqualTo = DateMath.FromString(node.Value.ToString()) });
    queriesList.Add(queryContainer);

    var results = elasticClient.Search<ChangeLog>(new SearchRequest<ChangeLog>("change-log")
                  {
                         Query = new BoolQuery { Must = queriesList }
                  });

```

Am I doing something wrong? why this code works perfectly for textual fields?  
The only change between search according to textual field is by using MatchQuery instead of DateRangeQuery:

```auto
    QueryContainer queryContainer = new QueryContainer(new MatchQuery { Field = GetCamelCaseString(this._currentKey), Query = node.Value.ToString() });

```

---

<div class="post-metadata">

**Author:** ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)\
**Post date:** [January 13, 2021, 10:40pm UTC](https://discuss.elastic.co/t/daterangequery-with-nest-results-with-server-error-400-all-shards-failed/261059/2 "2021-01-13T22:40:07Z")

</div>

Welcome to our community! 😃

Is there more to the error? Is there anything in the Elasticsearch logs at that time?

---

<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:** [February 10, 2021, 10:40pm UTC](https://discuss.elastic.co/t/daterangequery-with-nest-results-with-server-error-400-all-shards-failed/261059/3 "2021-02-10T22:40:07Z")

</div>

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