Skip to content

DocumentAdapters converts sort values to string #2777

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

Closed
whalewired opened this issue Nov 21, 2023 · 3 comments · Fixed by #2786
Closed

DocumentAdapters converts sort values to string #2777

whalewired opened this issue Nov 21, 2023 · 3 comments · Fixed by #2786
Assignees
Labels
type: bug A general bug

Comments

@whalewired
Copy link

When upgrading from 4.2.12 to 5.1.5 search_after on sorted date fields, that does not specify pattern, no longer works.

In 4.2.12 the returned sort value was Long (epoch_millis).

In 5.1.5 it is converted to a String.

It happens her:

org.springframework.data.elasticsearch.client.elc.DocumentAdapters

return new SearchDocumentAdapter(document, score, hit.sort().stream().map(TypeUtils::toString).toArray(),
				documentFields, highlightFields, innerHits, nestedMetaData, explanation, matchedQueries, hit.routing());

If that String is used in search_after Elasticsearch fails with "failed to parse date field".

When it stays as a Long it works fine.

One could add "format" pattern to the sort part to fix this so it uses that pattern consistently, but the use of Long also worked, so my question is, why are these converted to string?

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Nov 21, 2023
@sothawo
Copy link
Collaborator

sothawo commented Nov 26, 2023

I have to check into this one. I remember that the new Elasticsearch client in the beginning used to always return the sort values in a String array, but they may have changed this in the meantime.

@sothawo sothawo self-assigned this Nov 30, 2023
@sothawo sothawo added type: bug A general bug and removed status: waiting-for-triage An issue we've not yet triaged labels Nov 30, 2023
sothawo added a commit to sothawo/spring-data-elasticsearch that referenced this issue Nov 30, 2023
sothawo added a commit that referenced this issue Nov 30, 2023
Original Pull Request #2786
Closes #2777
@sothawo sothawo added this to the 5.3 M1 (2024.0.0) milestone Nov 30, 2023
sothawo added a commit that referenced this issue Nov 30, 2023
Original Pull Request #2786
Closes #2777

(cherry picked from commit 3833975)
sothawo added a commit that referenced this issue Nov 30, 2023
Original Pull Request #2786
Closes #2777

(cherry picked from commit 3833975)
(cherry picked from commit 0fb98ed)
@whalewired
Copy link
Author

Will this go into 5.1.7?

@sothawo
Copy link
Collaborator

sothawo commented Dec 8, 2023

Will this go into 5.1.7?

yes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug A general bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants