Kibana JSON Input Aggregation Query

Hi Friends,

I have created a Pie Chart in Kibana with JSON Input and it generates the following request. Could somebody explain what this query is doing on the aggregation part?

I seem that have an aggregation 'line_id' and '_source.text_entry.length()'.
Thanks.

{
"size": 0,
"query": {
"query_string": {
"analyze_wildcard": true,
"query": "*"
}
},
"aggs": {
"2": {
"terms": {
"field": "line_id",
"size": 10,
"order": {
"_count": "desc"
},
"script": "_source.text_entry.length()",
"lang": "groovy"
}
}
}
}

Top 10 Terms aggregation on the field "line_id", passing a script which I assume you defined?

Yes I passed it the script indeed... How does the script influence the top 10 Terms aggregation here above?
Mark

The function of the script is explained in the Elasticsearch documentation for the Terms aggregation:
https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-terms-aggregation.html#search-aggregations-bucket-terms-aggregation-script

What are you trying to achieve with this script?

Thanks for your help!

My goal is to explore, I was trying the JSON Input functionality in Kibana. I passed this scripts and it indeed influence my result query. However it is unclear to me how it influence this JSON Aggregation Query.

Maybe you could write this query explicitly and completely? I think it would clarify what the extra statement with the script adds to this aggregation query.