Hi,
I've enabled the _size plugin and now I'm trying to get the average document size with the following query:
{
"query": {
"match_all": {}
},
"aggs": {
"avg_size": {
"avg": {
"terms": {
"field": "_size"
}
}
}
}
}
But for some reason, it fails with the following error:
RemoteTransportException[[mng01][10.21.254.254:9300][indices:data/read/search[phase/query]]]; nested: SearchParseException[failed to parse search source [{
"query": {
"match_all": {}
},
"aggs": {
"avg_size": {
"avg": {
"terms": {
"field": "_size"
}
}
}
}
}]]; nested: SearchParseException[Unexpected token START_OBJECT in [avg_size].];
Caused by: SearchParseException[failed to parse search source [{
"query": {
"match_all": {}
},
"aggs": {
"avg_size": {
"avg": {
"terms": {
"field": "_size"
}
}
}
}
}]]; nested: SearchParseException[Unexpected token START_OBJECT in [avg_size].];
at org.elasticsearch.search.SearchService.parseSource(SearchService.java:873)
at org.elasticsearch.search.SearchService.createContext(SearchService.java:667)
at org.elasticsearch.search.SearchService.createAndPutContext(SearchService.java:633)
at org.elasticsearch.search.SearchService.executeQueryPhase(SearchService.java:377)
at org.elasticsearch.search.action.SearchServiceTransportAction$SearchQueryTransportHandler.messageReceived(SearchServiceTransportAction.java:368)
at org.elasticsearch.search.action.SearchServiceTransportAction$SearchQueryTransportHandler.messageReceived(SearchServiceTransportAction.java:365)
at org.elasticsearch.transport.TransportRequestHandler.messageReceived(TransportRequestHandler.java:33)
at org.elasticsearch.transport.RequestHandlerRegistry.processMessageReceived(RequestHandlerRegistry.java:77)
at org.elasticsearch.transport.TransportService$4.doRun(TransportService.java:376)
at org.elasticsearch.common.util.concurrent.AbstractRunnable.run(AbstractRunnable.java:37)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
Caused by: SearchParseException[Unexpected token START_OBJECT in [avg_size].]
at org.elasticsearch.search.aggregations.metrics.NumericValuesSourceMetricsAggregatorParser.parse(NumericValuesSourceMetricsAggregatorParser.java:61)
at org.elasticsearch.search.aggregations.AggregatorParsers.parseAggregators(AggregatorParsers.java:198)
at org.elasticsearch.search.aggregations.AggregatorParsers.parseAggregators(AggregatorParsers.java:103)
at org.elasticsearch.search.aggregations.AggregationParseElement.parse(AggregationParseElement.java:60)
at org.elasticsearch.search.SearchService.parseSource(SearchService.java:856)
... 12 more
Any idea on how to avoid this issue? I want to get average document size stored on ES, and maybe some histogram too.