-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SearchAfter does not support date types, and all types except string types are cast; Will cause pagination exceptions #2678
Labels
type: bug
A general bug
Milestone
Comments
spring-projects-issues
added
the
status: waiting-for-triage
An issue we've not yet triaged
label
Aug 28, 2023
sothawo
added a commit
to sothawo/spring-data-elasticsearch
that referenced
this issue
Aug 28, 2023
sothawo
added a commit
that referenced
this issue
Aug 28, 2023
sothawo
added
type: bug
A general bug
and removed
status: waiting-for-triage
An issue we've not yet triaged
labels
Aug 28, 2023
You are right, that But hardcoding a numeric value is wrong as well, the array can contain any type if data, from numeric, to strings or boolean values or other objects. #2679 fixes this by creating the correct |
sothawo
added a commit
that referenced
this issue
Aug 28, 2023
sothawo
added a commit
that referenced
this issue
Aug 28, 2023
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
There is an issue with sorting and pagination of date fields. If the date is a null value, the searchAfter pagination will stay in place and will not search for new records. The main issue should be in/org/springframework/data/lastsearch/client/elc/RequestConverter. java: 1378 line:
If (! IsEmpty (query. getSearchAfter())){
}
The code at this point requires that the SortValue of the date type field also be cast to FieldValue. of (it. toString()).
But I feel like I should use FieldValue of (long value) for the date type{
Return new FieldValue (Kind. Long, value);
}Just replace the logic here.
Because the date field returned by getSortValues () is a long integer in string form called 'epoch_millis'.
Even if I take the epoch myself_ Converting Millis to a string formatted with a date [uuuu MM dd] cannot solve the problem, as epoch is returned when date=null_ Millis is an illegal date.
The code is roughly as follows:
ElasticsearchOperations ElasticsearchOperations;
org.springframework.data.elasticsearch.client.elc.NativeQuery query,
List afterObjs=new ArrayList<>(from below lastsortHit. getSortValues());
Query query. setSearchAfter (afterObjs);
SearchHits
searchHits=ElasticsearchOperations. search (query, myClassType);
List<SearchHit
> hits=searchHits. getSearchHits();
SearchHit lastsortHit=hits. get (Maxs-1);
List afterObjs= lastsortHit.getSortValues();
笔记
The text was updated successfully, but these errors were encountered: