You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Executing a search request that has sorting in it will produce SearchHits results where each Hit will have it's sort array field populated. However the sort array is always deserialized as string array and if one wants to use this value to repeat the request with search_after being set to the returned value of the sort this could result in an error from the server if the field type is not actually string.
However during deserialization the client will deserialize the sort field to
"sort": [
"1720256355885"
]
Thus repeating the request with search after will produce an error. Something like
"root_cause": [
{
"type": "parse_exception",
"reason": "failed to parse date field [1720256355885] with format [date_time]: [failed to parse date field [1720256355885] with format [date_time]]"
}
]
What is the expected behavior?
The returned value types of the sort field must be maintained as returned from the server.
What is your host/environment?
SpringBoot application
Do you have any additional context?
The issue seems to be related with the internal Hit generated class and the deserializer associated with the sort member - check here
Elastic java client seems to have addressed the same issue by changing the type of the sort member from List<String> to List<FieldValue>. Check this commit
The text was updated successfully, but these errors were encountered:
A workaround for this was released as of version 2.15.0, you can use sortVals (instead of sort) to get them as List<FieldValue> rather than List<String>.
For version 3.0.0 the sort itself will be changed to directly return List<FieldValue>.
This mirrors the workaround and future change for #755 which introduced a matching searchAfterVals on SearchRequest.
What is the bug?
Executing a search request that has sorting in it will produce SearchHits results where each Hit will have it's
sort
array field populated. However thesort
array is always deserialized as string array and if one wants to use this value to repeat the request withsearch_after
being set to the returned value of thesort
this could result in an error from the server if the field type is not actually string.How can one reproduce the bug?
Create an index which has the following mapping
Java field definition
Add a few documents that get indexed and then execute a search request followed by another search that utilizes
search_after
. For exampleWhen executing the above code the server will return something like
However during deserialization the client will deserialize the
sort
field toThus repeating the request with search after will produce an error. Something like
What is the expected behavior?
The returned value types of the
sort
field must be maintained as returned from the server.What is your host/environment?
SpringBoot application
Do you have any additional context?
sort
member - check heresort
member fromList<String>
toList<FieldValue>
. Check this commitThe text was updated successfully, but these errors were encountered: