Skip to content

Added key field to filter bucket agg #5013

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

Merged
merged 1 commit into from
Jul 22, 2025
Merged

Added key field to filter bucket agg #5013

merged 1 commit into from
Jul 22, 2025

Conversation

l-trotta
Copy link
Contributor

@l-trotta l-trotta commented Jul 22, 2025

As reported in a Java client issue, the FiltersBucket aggregation result can have a key field if keyed was set as false in the request.

No server code, key is a common field in aggregation and I couldn't find where it's added to the FiltersAggregation result.

server code

Here's a reproducer:

PUT /logs/_bulk?refresh
{ "index" : { "_id" : 1 } }
{ "body" : "warning: page could not be rendered" }
{ "index" : { "_id" : 2 } }
{ "body" : "authentication error" }
{ "index" : { "_id" : 3 } }
{ "body" : "warning: connection timed out" }
GET logs/_search
{
  "size": 0,
  "aggs" : {
    "messages" : {
      "filters" : {
        "filters" : {
          "errors" :   { "match" : { "body" : "error"   }},
          "warnings" : { "match" : { "body" : "warning" }}
        },
        "keyed": false
      }
    }
  }
}

Response without "keyed": false is:

  "aggregations": {
    "messages": {
      "buckets": {
        "errors": {
          "doc_count": 1
        },
        "warnings": {
          "doc_count": 2
        }
      }
    }
  }

with "keyed": false it's:

  "aggregations": {
    "messages": {
      "buckets": [
        {
          "key": "errors",
          "doc_count": 1
        },
        {
          "key": "warnings",
          "doc_count": 2
        }
      ]
    }
  }

Copy link
Contributor

Following you can find the validation changes against the target branch for the APIs.

No changes detected.

You can validate these APIs yourself by using the make validate target.

@l-trotta l-trotta merged commit 80b7017 into main Jul 22, 2025
18 checks passed
@l-trotta l-trotta deleted the filters-bucket-fix branch July 22, 2025 12:55
github-actions bot pushed a commit that referenced this pull request Jul 22, 2025
github-actions bot pushed a commit that referenced this pull request Jul 22, 2025
github-actions bot pushed a commit that referenced this pull request Jul 22, 2025
github-actions bot pushed a commit that referenced this pull request Jul 22, 2025
github-actions bot pushed a commit that referenced this pull request Jul 22, 2025
l-trotta added a commit that referenced this pull request Jul 22, 2025
(cherry picked from commit 80b7017)

Co-authored-by: Laura Trotta <[email protected]>
l-trotta added a commit that referenced this pull request Jul 22, 2025
(cherry picked from commit 80b7017)

Co-authored-by: Laura Trotta <[email protected]>
l-trotta added a commit that referenced this pull request Jul 22, 2025
(cherry picked from commit 80b7017)

Co-authored-by: Laura Trotta <[email protected]>
l-trotta added a commit that referenced this pull request Jul 22, 2025
(cherry picked from commit 80b7017)

Co-authored-by: Laura Trotta <[email protected]>
l-trotta added a commit that referenced this pull request Jul 22, 2025
(cherry picked from commit 80b7017)

Co-authored-by: Laura Trotta <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants