# Error runnig query, trying to order by 2 aggregated term fields elastic 1.1

**URL:** <https://discuss.elastic.co/t/error-runnig-query-trying-to-order-by-2-aggregated-term-fields-elastic-1-1/18072>\
**Category:** Elasticsearch\
**Created:** [June 12, 2014, 5:00pm UTC](https://discuss.elastic.co/t/error-runnig-query-trying-to-order-by-2-aggregated-term-fields-elastic-1-1/18072 "2014-06-12T17:00:35Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jose\_Ignacio\_Diez](https://avatars.discourse-cdn.com/v4/letter/j/3bc359/32.png) [@Jose\_Ignacio\_Diez](https://discuss.elastic.co/u/Jose_Ignacio_Diez)\
**Post date:** [June 12, 2014, 5:00pm UTC](https://discuss.elastic.co/t/error-runnig-query-trying-to-order-by-2-aggregated-term-fields-elastic-1-1/18072/1 "2014-06-12T17:00:35Z")

</div>

Hi, I have a big issue with this. The query I'm running doesnt show the  
result expected. becauser It doesn let me to order for more than one  
aggregated term fields

GET my\_stats/stats/\_search  
{  
"size" : 0,  
"query" : {  
"filtered" : {  
"query" : {  
"match\_all" : { }  
},  
"filter" : {  
"bool" : {  
"must" : [ {  
"term" : {  
"MYID" : ["130037364"]  
}  
} ]  
}  
}  
}  
},  
"aggregations" : {  
"stats" : {  
"terms" : {  
"field" : "ADID",  
"size" : 15000,  
"order" : {  
"LISTED.value" : "desc" ,  
"DETAIL.value" : "desc"  
}  
},  
"aggregations" : {  
"LISTED" : {  
"sum" : {  
"field" : "LISTED"  
}  
},  
"DETAIL" : {  
"sum" : {  
"field" : "DETAIL"  
}  
},  
"ALERTS" : {  
"sum" : {  
"field" : "ALERTS"  
}  
}  
}  
}  
}  
}

Any suggestion?

--  
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+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/a6851796-914c-4bcf-96e3-017e6b0b6431%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/a6851796-914c-4bcf-96e3-017e6b0b6431%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [July 6, 2017, 1:22am UTC](https://discuss.elastic.co/t/error-runnig-query-trying-to-order-by-2-aggregated-term-fields-elastic-1-1/18072/2 "2017-07-06T01:22:59Z")

</div>


