-
Notifications
You must be signed in to change notification settings - Fork 258
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
Adding aggregations that keep the original adding order in source code #932
Comments
Hello! I'm waiting to have more information from the server team on this one, since the clients were build with the idea that order of json fields at the same level never mattered. In the meantime, this query can be executed as is by bypassing the java client and using the underlying Rest Client: // Create the low-level client
try (RestClient restClient = RestClient
.builder(HttpHost.create(serverUrl))
.setDefaultHeaders(new Header[]{
new BasicHeader("Authorization", "ApiKey " + apiKey),
})
.build()) {
Request request = new Request("GET", "/_search");
request.addParameter("index", "index");
request.setJsonEntity("copypaste-query-here");
Response binaryRes = restClient.performRequest(request);
} The response will have to be read from the binary, but then you should be able to deserialize it into a dsl SearchResponse. I'll update this as soon as I have more information! |
@l-trotta |
Description
Java API client version
8.10.4
Java version
Java 17
Elasticsearch Version
8.11.4
Problem description
I have an Elasticsearch query like below, where I try to take the aggregations, filter with bucket_filter then do pagination with bucket_paging. If I execute this exact query, I get the correct output as expected. But if I switch the order of bucket_filter and bucket_paging in query, it returns less documents than expected. As guess that, with the later case, Elasticsearch executes the bucket_paging paging first (that return max 50 items), then applies the bucket_filter filter, that in turn filters out a few more items from previous 50 items.
I have also contacted with ElasticSearch support team and they confirmed that the order of pipeline aggregations (like bucket_selector and bucket_sort) does matter the query result.
My problem is, I'm using elasticsearch-java client library to build the query, which put aggregations into a map instead of a list, as a result the order of aggregations are random in the final built query.
Is there's any workaround so that I can fix this?
Source code (Kotlin):
The query:
The text was updated successfully, but these errors were encountered: