Skip to content
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

[BUG] SearchAfter only allows List<Strings> as type. #755

Closed
ahmadSibai opened this issue Dec 4, 2023 · 4 comments
Closed

[BUG] SearchAfter only allows List<Strings> as type. #755

ahmadSibai opened this issue Dec 4, 2023 · 4 comments
Labels
bug Something isn't working

Comments

@ahmadSibai
Copy link

What is the bug?

_OpenSearch search request search_after must accept any type of variables, in order to be able to paginate using the search_after feature.
The type defined in SearchRequest.java only accepts List<String>. This prevents any other non-String sort value from a previous query to be used in the proper type, causing the search query to fail.

The SearchResponse also casts any value from the hits.sort() to String.

How can one reproduce the bug?

  1. Create a query with a sort value on a field that is not of type String.
  2. Collect the sort value of your last hit
  3. Create a copy of your first query, but add a searchAfter key with value of the List collected in step 2.
  4. Notice how these values would have to be of type String. Try calling the query and notice how the shards will fail, returning 0 hits.

What is the expected behavior?

Expected behaviour is for the sort value to be in the original type, and for SearchAfter to be capable of being of that Type.

What is your host/environment?

AOSS

Do you have any screenshots?

No, but you can see here

Do you have any additional context?

Add any other context about the problem.

@ahmadSibai ahmadSibai added bug Something isn't working untriaged labels Dec 4, 2023
@dblock dblock removed the untriaged label Dec 4, 2023
@dblock
Copy link
Member

dblock commented Dec 4, 2023

What does the API spec say about this field? Is it supposed to accept a non-String type? https://github.com/opensearch-project/opensearch-api-specification may need to be modified.

@ahmadSibai
Copy link
Author

Opensearch documentation states that the search_after field should have the same values and types of the sort field, which can be a non-String. Please see reference here. The examples clearly show how it can be a list of an integer and String.

"search_after": [ 1, "32635"],

@dblock
Copy link
Member

dblock commented Dec 6, 2023

Thanks. If you have time, write a test that doesn't compile and maybe see if it's easy to fix?

@channel-dante
Copy link
Contributor

close this issue? This issue has been resolved. However, since it is not backward compatible, it will be applied to version 3.x.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants