I've been struggling to create term aggregations using the typed client v8.13.1, and am wondering whether I've uncovered a bug.
To start, I've created three simple test documents like the following:
{
"type": "A"
}
"type" is a text field with a keyword subfield. Using curl , I run the following aggregation perfectly fine:
curl --location 'http://localhost:9200/agg-test/_search' \
--header 'Content-Type: application/json' \
--data '{
"size": 0,
"aggregations": {
"type_buckets": {
"terms": {
"field": "type.keyword"
}
}
}
}'
which results in the following:
{
"took": 184,
"timed_out": false,
"_shards": {
"total": 1,
"successful": 1,
"skipped": 0,
"failed": 0
},
"hits": {
"total": {
"value": 3,
"relation": "eq"
},
"max_score": null,
"hits": []
},
"aggregations": {
"type_buckets": {
"doc_count_error_upper_bound": 0,
"sum_other_doc_count": 0,
"buckets": [
{
"key": "A",
"doc_count": 2
},
{
"key": "B",
"doc_count": 1
}
]
}
}
}
In trying to reproducing this using the typed client, I've defined the aggregation like so in Go:
resp, err := es.Search().Index("agg-test").
Request(&search.Request{
Size: some.Int(0),
Aggregations: map[string]types.Aggregations{
"type_buckets": {
Terms: &types.TermsAggregation{
Field: some.String("type.keyword"),
},
},
},
}).
Do(context.Background())
however, the response aggregation has 824637408744 buckets, all but the first of which has a doc count of 0. The bucket key is also nil, and I'm seeing the following docCountError:
unreadable: protocol error E08 during memory read for packet $m2,8
I'm hoping someone can confirm whether this is indeed a defect in the typed client or a misuse of it.