opensearch-project / opensearch-project/opensearch-java
[FEATURE] Add support for nested multi-bucket terms aggregation.
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 165
- Forks
- 250
- Avg merge
- 1d 18h
- Merged PRs (30d)
- 26
Description
Is your feature request related to a problem?
Currently only single-bucket nested aggregation are supported. So reading a response to a search request with nested terms aggregation seems impossible.
What solution would you like?
Add a new Aggregate kind called NestedTermsMultiBucket with the .buckets() method returning Buckets<NestedTermsBucket> and each NestedTermsBucket having a .key(), .docCount() and .aggregations() method.
What alternatives have you considered?
The only plausible alternative is just using an HTTP client and parsing a raw JSON.
Do you have any additional context?
Example request:
{
"size": 0,
"aggs": {
"outer": {
"terms": {
"field": "application",
"size": 9999
},
"aggs": {
"inner": {
"terms": {
"field": "eventCategory",
"size": 9999
}
}
}
}
}
}
Example response:
{
"took": 86,
"timed_out": false,
"_shards": {
"total": 1,
"successful": 1,
"skipped": 0,
"failed": 0
},
"hits": {
"total": {
"value": 114,
"relation": "eq"
},
"max_score": null,
"hits": []
},
"aggregations": {
"outer": {
"doc_count_error_upper_bound": 0,
"sum_other_doc_count": 0,
"buckets": [
{
"key": "dataModel",
"doc_count": 66,
"inner": {
"doc_count_error_upper_bound": 0,
"sum_other_doc_count": 0,
"buckets": [
{
"key": "Success",
"doc_count": 66
}
]
}
},
{
"key": "sed",
"doc_count": 35,
"inner": {
"doc_count_error_upper_bound": 0,
"sum_other_doc_count": 0,
"buckets": [
{
"key": "Success",
"doc_count": 32
},
{
"key": "Failure",
"doc_count": 3
}
]
}
},
{
"key": "Mon",
"doc_count": 7,
"inner": {
"doc_count_error_upper_bound": 0,
"sum_other_doc_count": 0,
"buckets": [
{
"key": "Success",
"doc_count": 7
}
]
}
},
{
"key": "alexandrina",
"doc_count": 6,
"inner": {
"doc_count_error_upper_bound": 0,
"sum_other_doc_count": 0,
"buckets": [
{
"key": "Success",
"doc_count": 6
}
]
}
}
]
}
}
}
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by tracing the existing Aggregate kinds and support for single-bucket nested aggregations in the Java client. Add the requested NestedTermsMultiBucket kind with buckets() returning Buckets, and provide key(), docCount(), and aggregations() on each bucket. Done means the example nested terms response can be read through these APIs rather than raw JSON.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- api
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100