-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Description
Elastic.Clients.Elasticsearch version: 8.9.0
Elasticsearch version: 8.8.1
.NET runtime version: 6.0
Operating system version: Windows 10
Description of the problem including expected versus actual behavior:
Number data types in search response hits source are lost (whether it is a double, int, etc.)
Steps to reproduce:
- Create index with the following mappings:
"category": {
"type": "keyword"
},
"availabilityValue": {
"type": "integer"
},
"dimension": {
"type": "double"
}
- Upload some documents
- Execute search request:
var result = client.SearchAsync<Dictionary<string, object>>(request);
In the older NEST client, the response hits source contained all fields in their respective data types, so it was easy to use them i.e.:
result.Hits.First().Source["category"].GetType().Name -> String
result.Hits.First().Source["availabilityValue"].GetType().Name -> Int32
result.Hits.First().Source["dimension"].GetType().Name -> Double
However, in the new Elastic.Clients.Elasticsearch client, these hit sources are JsonElements, where type of number is lost:
result.Hits.First().Source["category"] -> ValueKind = String
result.Hits.First().Source["availabilityValue"] -> ValueKind = Number
result.Hits.First().Source["dimension"] -> ValueKind = Number
For the 2 numbers, the information whether it was originally a double or int is lost, so we are unable to decide whether to call GetInt32 or GetDouble on the json element to get its value.
I'm not sure whether it's a bug, or there's a solution to our problem that we are not aware of.
Thank you in advance!