Hi On Thu, May 22, 2014 at 1:47 PM, bagui [via ElasticSearch Users] < ml-node+s115913n4056274...@n3.nabble.com> wrote:
Hi, > > I want to get the average value of MEMORY field from my ES document. Below > is the query I'm using for that. Here I'm getting the aggregation along > with the hits Json also. Is there any way we can get the aggreation result > only. Please suggest. > > POST /virtualmachines/_search > { > "query" : { > "filtered" : { > "query" : { "match" : { > "CLOUD_TYPE" : "CLOUDSTACK" > }}, > "filter" : { > "range" : { "NODE_CREATE_TIME" : { "from" : "2014-05-22 > 14:11:35", "to" : "2014-05-22 14:33:35" }} > } > } > }, > "aggs" : { > "memory_avg" : { "avg" : { "field" : "MEMORY" } } > } > } > > This is how I do it: Simply add a post_filter with a term query for a non-existent term or a value which is not possible (e.g. -1 for a positive integer field). I am sure there are cleaner ways but this works for me em -- View this message in context: http://elasticsearch-users.115913.n3.nabble.com/how-to-get-only-aggregation-values-from-elasticsearch-tp4056274p4056286.html Sent from the ElasticSearch Users mailing list archive at Nabble.com. -- You received this message because you are subscribed to the Google Groups "elasticsearch" group. To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/CAE6dBgh0dQvDW%2BfX1VhMzfZVDxOpKoFx6yoANcPDpkhHYmM%2B%3Dg%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.