Can I use a query like that to calculate the average size of documents in indexes if I don't have the _size enable at index level but I have the _source enabled?
{
"query" : {"match_all" : {}},
"aggs":{
"avg_length" : { "avg" : { "script" : "_source.toString().length()"}}
}
}
Act
Well, this is the char count. If strings are UTF-8 a think I can get the byte count with
"query" : {"match_all" : {}},
"aggs":{
"avg_length" : { "avg" : { "script" : "_source.toString().getBytes(\"UTF-8\").length"}}
}
}
Thanks