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

Multisearch requests in new Java API do not support “sort” or “searchAfter” properties #170

Closed
AJovcheska opened this issue Feb 24, 2022 · 5 comments · Fixed by #292
Labels
Area: Specification Related to the API spec used to generate client code

Comments

@AJovcheska
Copy link

SearchRequest offers the possibility to set the 'sort' or 'searchAfter' property, but in MSearchRequest this is missing. It is not available in MultisearchHeader not MultisearchBody in the RequestItem.

@jerryguowei
Copy link

jerryguowei commented Mar 11, 2022

We also got the same issue. Actually there are many properties missing in the MultisearchBody. For example version, _source, _source_excludes, _source_includes etc. Is there any plan to add those properties as well?

When using HLRC, we are using org.elasticsearch.action.search.MultiSearchRequest, which has code to write the header and body

    public static byte[] writeMultiLineFormat(MultiSearchRequest multiSearchRequest, XContent xContent) throws IOException {
        ByteArrayOutputStream output = new ByteArrayOutputStream();
        for (SearchRequest request : multiSearchRequest.requests()) {
            try (XContentBuilder xContentBuilder = XContentBuilder.builder(xContent)) {
                writeSearchRequestParams(request, xContentBuilder);
                BytesReference.bytes(xContentBuilder).writeTo(output);
            }
            output.write(xContent.streamSeparator());
            try (XContentBuilder xContentBuilder = XContentBuilder.builder(xContent)) {
                if (request.source() != null) {
                    request.source().toXContent(xContentBuilder, ToXContent.EMPTY_PARAMS);
                } else {
                    xContentBuilder.startObject();
                    xContentBuilder.endObject();
                }
                BytesReference.bytes(xContentBuilder).writeTo(output);
            }
            output.write(xContent.streamSeparator());
        }
        return output.toByteArray();
    }

We can see that request.source().toXContent(xContentBuilder, ToXContent.EMPTY_PARAMS); is to write code to body, and the source() actually returnsorg.elasticsearch.search.builder.SearchSourceBuilder, in other words, all the parameters in the SearchSourceBuilder builder should be included in the body.

@swallez
Copy link
Member

swallez commented May 24, 2022

This has been fixed in PR #292, backported to version 8.2 in PR #293 and to version 7.17 in PR #294.

@AJovcheska
Copy link
Author

Hi. It says backported to version 7.17, so I assumed that the fix should be present in 7.17.4 as last released version for 7.17. But the new properties are not present there. I checked in the source code: https://github.com/elastic/elasticsearch-java/releases/tag/v7.17.4. The 7.17.4 release happened on the same day as the merging of the PR. Can you please tell me which version to use? In my project we are using 7.17.1, so we still don't want to update to 8.x, as some other major change may come.
Thank you.

@AJovcheska
Copy link
Author

Update from my side: I checked out the repo and saw that the tag for 7.17.4 was done on May 3rd, and the task was merged on May 24. So the changes are not present in 7.17.x release. Can you please release them under 7.17?

@swallez
Copy link
Member

swallez commented Jul 13, 2022

@AJovcheska the changes are present in version 7.17.5.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: Specification Related to the API spec used to generate client code
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants