Sort failing due to serialization error
See original GitHub issueWhen I apply a sort, the response is throwing an error when trying to convert the hits back to concrete types.
After looking into the code, it appears that the _score is null when a sort is applied. However, it fails to convert and throws an error. If I set TrackScores to true, it works correctly (_score comes back as 0 in this case). This happens on line 125 in https://github.com/elastic/elasticsearch-net/blob/master/src/Nest/CommonAbstractions/SerializationBehavior/StatefulDeserialization/ConcreteTypeConverter.cs
Here is the exception:
Microsoft.CSharp.RuntimeBinder.RuntimeBinderException was unhandled by user code
HResult=-2146233088
Message=Cannot implicitly convert type ‘Newtonsoft.Json.Linq.JValue’ to ‘double’. An explicit conversion exists (are you missing a cast?)
Source=Anonymously Hosted DynamicMethods Assembly
StackTrace:
at CallSite.Target(Closure , CallSite , Object )
at Nest.ConcreteTypeConverter.GetConcreteTypeUsingSelector[T](JsonSerializer serializer, ConcreteTypeConverter1 realConcreteConverter, JObject jObject) in c:\code\elasticsearch-net\src\Nest\CommonAbstractions\SerializationBehavior\StatefulDeserialization\ConcreteTypeConverter.cs:line 125 at Nest.ConcreteTypeConverter.GetUsingConcreteTypeConverter[T](JsonReader reader, JsonSerializer serializer, ConcreteTypeConverter
1 realConcreteConverter) in c:\code\elasticsearch-net\src\Nest\CommonAbstractions\SerializationBehavior\StatefulDeserialization\ConcreteTypeConverter.cs:line 83
at Nest.ConcreteTypeConverter`1.ReadJson(JsonReader reader, Type objectType, Object existingValue, JsonSerializer serializer) in c:\code\elasticsearch-net\src\Nest\CommonAbstractions\SerializationBehavior\StatefulDeserialization\ConcreteTypeConverter.cs:line 62
at Nest.DefaultHitJsonConverter.ReadJson(JsonReader reader, Type objectType, Object existingValue, JsonSerializer serializer) in c:\code\elasticsearch-net\src\Nest\CommonAbstractions\SerializationBehavior\StatefulDeserialization\ConcreteTypeConverter.cs:line 24
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.DeserializeConvertable(JsonConverter converter, JsonReader reader, Type objectType, Object existingValue)
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.PopulateList(IList list, JsonReader reader, JsonArrayContract contract, JsonProperty containerProperty, String id)
InnerException:
Issue Analytics
- State:
- Created 8 years ago
- Comments:5 (2 by maintainers)
Top GitHub Comments
I will work on a simple example that reproduces the issue. I am using 2.0.2.
Thank you all for reporting this. It’ll be fixed in the next release.