# Upgrade to NEST 5.0.0.0 and Elastic search 5.0.0.0 issue error 400 but with Kibana it is working fine and extracts result

**URL:** https://discuss.elastic.co/t/upgrade-to-nest-5-0-0-0-and-elastic-search-5-0-0-0-issue-error-400-but-with-kibana-it-is-working-fine-and-extracts-result/110301
**Category:** Elasticsearch
**Created:** [December 5, 2017, 9:44am UTC](https://discuss.elastic.co/t/upgrade-to-nest-5-0-0-0-and-elastic-search-5-0-0-0-issue-error-400-but-with-kibana-it-is-working-fine-and-extracts-result/110301 "2017-12-05T09:44:39Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![dibyajyoti\_dev](https://avatars.discourse-cdn.com/v4/letter/d/13edae/32.png) [@dibyajyoti\_dev](https://discuss.elastic.co/u/dibyajyoti_dev)
#### Post date: [December 5, 2017, 9:44am UTC](https://discuss.elastic.co/t/upgrade-to-nest-5-0-0-0-and-elastic-search-5-0-0-0-issue-error-400-but-with-kibana-it-is-working-fine-and-extracts-result/110301/1 "2017-12-05T09:44:39Z")

</div>

Hi ,

I got upgraded my MVC app to NEST and elastic version 5.0.0.0 and as I see the documentation about size parameter should be greater than 0 i did put Size(10). as below.

> var response = Elastic  
> .Search(selector =\> selector  
> .Index(indexesToQuery)  
> .Aggregations(aggs =\> aggs  
> .Terms("app", appTerm =\> appTerm  
> .Size (10)  
> .Field(l =\> l.ApplicationCode)  
> .Aggregations(appAggs =\> appAggs  
> .Terms("module", moduleTerm =\> moduleTerm  
> .Size(10)  
> .Field(l =\> l.Module)  
> .Aggregations(moduleAggs =\> moduleAggs  
> .Terms("log-levels", t =\> t  
> .Size(10)  
> .Field(l =\> l.LogLevel)  
> .Aggregations(lla =\> lla  
> .DateRange("by-date-range",  
> dateRange =\> dateRange  
> .Field(l =\> l.EventUtcTimestamp)  
> .Ranges(r =\> r.From(new DateMathExpression(dateRangeStart)).To(new DateMathExpression(dateRangeEnd))))  
> )  
> )  
> )  
> )  
> )  
> )  
> )  
> .Size(10)  
> );

The error stack is below with error 400

_ **Invalid NEST response built from a unsuccessful low level call on POST: /log-messages-20171205%2A/logmessage/\_search** _  
_ **# Audit trail of this API call:** _  
_\*\* - [1] BadResponse: Node: [http://test.application.companyName.com:9200/](http://test.application.companyName.com:9200/) Took: 00:00:00.6054258\*\*_  
_ **# ServerError: ServerError: 400Type: search\_phase\_execution\_exception Reason: "all shards failed"** _  
_**# OriginalException: System.Net.WebException: The remote server returned an error: (400) Bad Request.**_  
_\*\* at System.Net.HttpWebRequest.GetResponse()\*\*_  
_\*\* at Elasticsearch.Net.HttpConnection.Request[TReturn](RequestData requestData)\*\*_  
_ **# Request:** _  
_**{"size":10,"aggs":{"app":{"terms":{"field":"applicationCode","size":10},"aggs":{"module":{"terms":{"field":"module","size":10},"aggs":{"log-levels":{"terms":{"field":"logLevel","size":10},"aggs":{"by-date-range":{"date\_range":{"field":"eventUtcTimestamp","ranges":[{"from":"2017-12-05T08:42:48.9641734Z","to":"2017-12-05T09:42:49.3565214Z"}]}}}}}}}}}}**_  
_ **# Response:** _  
_**{"error":{"root\_cause":[{"type":"illegal\_argument\_exception","reason":"Fielddata is disabled on text fields by default. Set fielddata=true on [applicationCode] in order to load fielddata in memory by uninverting the inverted index. Note that this can however use significant memory. Alternatively use a keyword field instead."}],"type":"search\_phase\_execution\_exception","reason":"all shards failed","phase":"query","grouped":true,"failed\_shards":[{"shard":0,"index":"log-messages-20171205","node":"7hBicvU8Seeyxn-yAT7Fcw","reason":{"type":"illegal\_argument\_exception","reason":"Fielddata is disabled on text fields by default. Set fielddata=true on [applicationCode] in order to load fielddata in memory by uninverting the inverted index. Note that this can however use significant memory. Alternatively use a keyword field instead."}}]},"status":400}**_

The node cannot be accessed as it is organisation specific and has to be kept private as per policies. Hope the stack trace rings a bell.

Any help would be much appreciated!

---

<div class="post-metadata">

### Author: ![forloop](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/forloop/32/9021_2.png) [@forloop](https://discuss.elastic.co/u/forloop)
#### Post date: [December 8, 2017, 12:04pm UTC](https://discuss.elastic.co/t/upgrade-to-nest-5-0-0-0-and-elastic-search-5-0-0-0-issue-error-400-but-with-kibana-it-is-working-fine-and-extracts-result/110301/2 "2017-12-08T12:04:09Z")

</div>

The error reason provides some good details on what the issue is

> [@dibyajyoti\_dev](#):
>
> Fielddata is disabled on text fields by default. Set fielddata=true on [applicationCode] in order to load fielddata in memory by uninverting the inverted index. Note that this can however use significant memory. Alternatively use a keyword field instead.

The `ApplicationCode` property is mapped as a `text` field datatype and the query is attempting to perform a terms aggregation on it. In order for this to work, [`fielddata` needs to be enabled on the field mapping as it is disabled by default](https://www.elastic.co/guide/en/elasticsearch/reference/5.0/fielddata.html), as fielddata on a large text field over many documents can consume a lot of memory and impede cluster performance.

As per the message and documentation, you may want to consider mapping the field also as a `keyword` datatype, using a multi\_field, and performing the aggregation on that field.

---

<div class="post-metadata">

### Author: ![dibyajyoti\_dev](https://avatars.discourse-cdn.com/v4/letter/d/13edae/32.png) [@dibyajyoti\_dev](https://discuss.elastic.co/u/dibyajyoti_dev)
#### Post date: [December 8, 2017, 12:48pm UTC](https://discuss.elastic.co/t/upgrade-to-nest-5-0-0-0-and-elastic-search-5-0-0-0-issue-error-400-but-with-kibana-it-is-working-fine-and-extracts-result/110301/3 "2017-12-08T12:48:33Z")

</div>

Thanks Russ Cam for your reply. Just wanted to re-visit on the same as in Kibana it all looks perfect and data is extracted.

The problem is when I use the NEST dll (version 5.0.0.0 which in turn uses elastic search 5.0.0.0). The same is not a problem with the lower version of NEST (in my MVC .Net App)neither in Kibana even with upgrade.

it clearly implies it is owing to NEST and elastic search upgrade. Hope my performance is not degraded with setting field data to true

---

<div class="post-metadata">

### Author: ![forloop](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/forloop/32/9021_2.png) [@forloop](https://discuss.elastic.co/u/forloop)
#### Post date: [December 10, 2017, 9:35pm UTC](https://discuss.elastic.co/t/upgrade-to-nest-5-0-0-0-and-elastic-search-5-0-0-0-issue-error-400-but-with-kibana-it-is-working-fine-and-extracts-result/110301/4 "2017-12-10T21:35:12Z")

</div>

> [@dibyajyoti\_dev](#):
>
> it clearly implies it is owing to NEST and elastic search upgrade.

It is not NEST, but a change in mapping following an upgrade. I would recommend changing over to [using `keyword` type if you can.](https://www.elastic.co/blog/strings-are-dead-long-live-strings)

---

<div class="post-metadata">

### Author: ![dibyajyoti\_dev](https://avatars.discourse-cdn.com/v4/letter/d/13edae/32.png) [@dibyajyoti\_dev](https://discuss.elastic.co/u/dibyajyoti_dev)
#### Post date: [December 12, 2017, 10:50am UTC](https://discuss.elastic.co/t/upgrade-to-nest-5-0-0-0-and-elastic-search-5-0-0-0-issue-error-400-but-with-kibana-it-is-working-fine-and-extracts-result/110301/5 "2017-12-12T10:50:58Z")

</div>

Thanks.. So I changed the code as below with inclusion of keyword **term =\> term.Field(l =\> l.Machine.Suffix("keyword"))**. is this the way ? Please note the field "Machine" is of type string

public static List GetMachinesList(string applicationCode)  
{  
var result = Elastic.Search(s =\> s  
.Index("log-messages-\*")  
.Query(q =\> q.Term(l =\> l.ApplicationCode, applicationCode))  
.Aggregations(aggs =\> aggs  
.Terms("machine-codes",  
term =\> term.Field(l =\> l.Machine.Suffix("keyword")).OrderAscending("\_term").Size(int.MaxValue))));

```
        return result.Aggs.Terms("machine-codes").Buckets.Select(b => b.Key).ToList();
    }
```

---

<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: [January 9, 2018, 10:51am UTC](https://discuss.elastic.co/t/upgrade-to-nest-5-0-0-0-and-elastic-search-5-0-0-0-issue-error-400-but-with-kibana-it-is-working-fine-and-extracts-result/110301/6 "2018-01-09T10:51:22Z")

</div>

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