Skip to content

Sort failing due to serialization error #1863

Closed
@curtismbeard

Description

@curtismbeard

When 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, ConcreteTypeConverter1 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:

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions