ES 7.x не поддерживает значение Doube.NaN
. Поэтому я сделал обходной путь, используя шаблон:
...
"numberOfDataPointsInRange": {
"type": "double",
"ignore_malformed": true
},
...
и дополнительно используя пользовательский JsonConverter
if (double.IsNaN(val))
{
// write NaN values as string
writer.WriteValue("NaN");
}
else
{
writer.WriteValue(val);
}
Не работает чтение / запись документов, содержащих какие-либо значения "NaN". Но выполнение, например, этого запроса приведет к ответу 4xx:
var searchRequest = new SearchRequest<DataPoint>(Indices.Parse(DataPointConstants.GetBatchIndexName(batchId)))
{
Size = 0, // We just need the aggregation data. Returned documents of the top level query are not required.
Query = new BoolQuery
{
MustNot = new List<QueryContainer>
{
//todo: does not work
new TermQuery { Field = DataPointConstants.DataPointFieldValue, Value = "NaN" }
}
},
Aggregations = new TermsAggregation(Bucketperparameter)
{
Field = DataPointConstants.DataPointFieldParameterId,
Aggregations = new ExtendedStatsAggregation(Parameterstats, DataPointConstants.DataPointFieldValue),
Size = 500
}
};
Ошибка явно вызвана запросом MustNot. Я подозреваю, что это проблема Elasticsearch.
Ошибка:
Invalid NEST response built from a unsuccessful (400) low level call on POST: /datapoints-batches-33-a/_search?typed_keys=true
# Audit trail of this API call:
- [1] BadResponse: Node: http://localhost:9200/ Took: 00:00:00.1645605
# OriginalException: Elasticsearch.Net.ElasticsearchClientException: The remote server returned an error: (400) Bad Request.. Call: Status code 400 from: POST /datapoints-batches-33-a/_search?typed_keys=true. S
erverError: Type: search_phase_execution_exception Reason: "all shards failed" ---> System.Net.WebException: The remote server returned an error: (400) Bad Request.
at System.Net.HttpWebRequest.EndGetResponse(IAsyncResult asyncResult)
at System.Threading.Tasks.TaskFactory`1.FromAsyncCoreLogic(IAsyncResult iar, Func`2 endFunction, Action`1 endAction, Task`1 promise, Boolean requiresSynchronization)
--- End of stack trace from previous location where exception was thrown ---