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] MultisearchBody or RequestItem missing sort property in msearch #612

Closed
mpr20001 opened this issue Aug 31, 2023 · 3 comments
Closed
Labels
bug Something isn't working good first issue Good for newcomers

Comments

@mpr20001
Copy link

What is the bug?

SearchRequest offers the possibility to set the 'sort' property, but this is missing in MultisearchBody or RequestItem.

How can one reproduce the bug?

GET index-name/_msearch
{}
{"sort":[{"search.count":{"order":"desc"}}],"from":0,"timeout":"60s","size":5,"query":{"bool":{"filter":{"percolate":{"field":"search.query","document":{"keyword":"This is a test sentence"}}}}}}
{"index": "index-name"}
{"sort":[{"search.count":{"order":"desc"}}],"from":0,"timeout":"60s","size":5,"query":{"bool":{"filter":{"percolate":{"field":"search.query","document":{"keyword":"This is test sentence 2"}}}}}}

Opensearch allows "sort" in the REST request but not with opensearch java client

        multiSearchBodyBuilder.sort(new SortOptions.Builder()
          .field(new FieldSort.Builder()
            .field(documentSearchRequest.sortFieldName)
            .order(documentSearchRequest.effectiveSortOrder)
            .build())
          .build())

throws

java.lang.NoSuchMethodError: 'org.opensearch.client.opensearch.core.msearch.MultisearchBody$Builder org.opensearch.client.opensearch.core.msearch.MultisearchBody$Builder.sort(org.opensearch.client.opensearch._types.SortOptions, org.opensearch.client.opensearch._types.SortOptions[])'

What is the expected behavior?

MultiSearchBody should allow sort functionality.

What is your host/environment?

opensearch java 2.6 .

Do you have any screenshots?

N/A

Do you have any additional context?

It looks like elasticsearch-java fixed this bug in 7.17.5 elastic/elasticsearch-java#170

@mpr20001 mpr20001 added bug Something isn't working untriaged labels Aug 31, 2023
@mpr20001 mpr20001 changed the title [BUG] [BUG] MultisearchBody or RequestItem missing sort property in msearch Aug 31, 2023
@dblock
Copy link
Member

dblock commented Aug 31, 2023

Want to try to implement this?

@VachaShah
Copy link
Collaborator

@mpr20001 The sort functionality was added in #516 and #519 (for 2.x) in version 2.6.0. An example of how to use the sort function is https://github.com/opensearch-project/opensearch-java/blob/main/java-client/src/test/java/org/opensearch/client/opensearch/integTest/AbstractMultiSearchRequestIT.java#L224. Can you please confirm if this still does not work for you?

@wbeckler wbeckler added the good first issue Good for newcomers label Sep 19, 2023
@VachaShah
Copy link
Collaborator

The requested functionality is added in the client. Please reopen this issue if you are still facing any errors. Thank you!

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

No branches or pull requests

4 participants