Versions (relevant - OpenSearch/Dashboard/Server OS/Browser):
Using gradle
dependencies {
implementation ‘org.opensearch.client:opensearch-rest-client: 2.5.0’
implementation ‘org.opensearch.client:opensearch-java:2.0.0’
}
Describe the issue:
According to the opensearch docs whenever we need to perform an aggregated query on multiple fields, it is just a matter to use multi_terms
aggregation like this:
GET my_index/_search
{
"query": {
"bool" : {
"must" : [
{"match" : {"my_field" : {"query" : "my value"}}}
]
}
},
"size": 0,
"aggs": {
"my_aggregate": {
"multi_terms": {
"size": 500,
"terms": [
{
"field": "second_field"
},
{
"field": "other_field"
}
]
}
}
}
}
where we can see how easy is to specify the number of buckets we want to retrieve by setting size=500
. The above aggregation can be translated to java like this:
new Aggregation.Builder()
.multiTerms(t -> t.terms(List.of(
MultiTermLookup.of(mt -> mt.field("second_field")),
MultiTermLookup.of(mt -> mt.field("other_field"))
))))
.build();
But it seems that the java client does not allow to specify the number of buckets to retrieve, then an aggregated query with multi_terms
always returns 10 buckets by default.
Is there any plans to allow multi_terms
in java client to set the size
parameter?