Closed as not planned
Description
Using a terms source in a composite aggregation is documented to fully support scripts in the same way as terms aggregation:
The terms value source is equivalent to a simple terms aggregation. The values are extracted from a field or a script exactly like the terms aggregation.
However, value script does not work as expected but is silently ignored.
Workaround
Instead of using _value
use doc[{field_name}]
Reproduction
The described behavior can be reproduced using the kibana sample data logs:
GET kibana_sample_data_logs/_search
{
"size": 0,
"aggs": {
"my_composite_agg": {
"composite": {
"sources": [
{
"agent": {
"terms": {
"field": "agent.keyword",
"script": {
"source": "'agent: ' + _value"}
}
}
}
]
}
}
}
}
returns e.g.
"buckets" : [
{
"key" : {
"agent" : "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322)"
},
"doc_count" : 4010
},
while the expected output is:
"buckets" : [
{
"key" : {
"agent" : "agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322)"
},
"doc_count" : 4010
},
I am not sure if this is really a bug or a technical limitation. If its a limitation the documentation should not claim full support and the search request using a value script should error.