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

[TypedClient] Can't parse SubAggregations #654

Closed
ludovic-franconieri opened this issue Apr 5, 2023 · 2 comments
Closed

[TypedClient] Can't parse SubAggregations #654

ludovic-franconieri opened this issue Apr 5, 2023 · 2 comments
Labels

Comments

@ludovic-franconieri
Copy link

Hello,

I was using the TypedClient to perform a search with multiple aggregations and I was not getting the result I expected.

Example:

Request:

GET /_search?typed_keys=true
{
  "aggs": {
    "genres": {
      "terms": {
        "field": "genre"
      },
      "aggs": {
        "max_play_count": { "max": { "field": "play_count" } }
      }
    }
  }
}

Response :

{
  ...
  "aggregations": {
    "terms#genres": {
      "doc_count_error_upper_bound": 0,   
      "sum_other_doc_count": 0,           
      "buckets": [                        
        {
          "key": "electronic",
          "doc_count": 6,
          "max#max_play_count": {
            "value": 40
          }
        },
        {
          "key": "rock",
          "doc_count": 3,
          "max#max_play_count": {
            "value": 20
          }
        },
        {
          "key": "jazz",
          "doc_count": 2,
          "max#max_play_count": {
            "value": 10
          }
        }
      ]
    }
  }
}

But as in the (s *StringTermsBucket) UnmarshalJSON function, the code is expecting an "aggregations" field, it won't be able to parse the reponse correctly.

As @Anaethelion pointed out, it should have something to do with the TypedClient's builder and the implementation of AdditionalProperties

I think that it concerns the class SingleBucketAggregateBase and MultiBucketBase as they both implements

  implements AdditionalProperties<AggregateName, Aggregate>

But unfortunately, I didn't find the builder for the TypedClient so I can't help you to resolve this issue 😕

Thanks,
Ludo

@xlucas
Copy link

xlucas commented Jun 1, 2023

This could be closed with the release of 8.7.1

@Anaethelion
Copy link
Contributor

Thanks for noticing, this should have been closed automatically.

Closing now!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants