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/ 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!