# Search by multiple aggregated fields, elastic 1.1

**URL:** <https://discuss.elastic.co/t/search-by-multiple-aggregated-fields-elastic-1-1/18042>\
**Category:** Elasticsearch\
**Created:** [June 11, 2014, 12:03pm UTC](https://discuss.elastic.co/t/search-by-multiple-aggregated-fields-elastic-1-1/18042 "2014-06-11T12:03:35Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![josidiez](https://avatars.discourse-cdn.com/v4/letter/j/ea5d25/32.png) [@josidiez](https://discuss.elastic.co/u/josidiez)\
**Post date:** [June 11, 2014, 12:03pm UTC](https://discuss.elastic.co/t/search-by-multiple-aggregated-fields-elastic-1-1/18042/1 "2014-06-11T12:03:35Z")

</div>

Hi, I'm a little bit newbie on this technology, so I was wondering if it's posible to order for more than one fields. this is my query:

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"  
}  
},  
"aggregations" : {  
"LISTED" : {  
"sum" : {  
"field" : "LISTED"  
}  
},  
"DETAIL" : {  
"sum" : {  
"field" : "DETAIL"  
}  
},  
"ALERTS" : {  
"sum" : {  
"field" : "ALERTS"  
}  
}  
}  
}  
}  
}

What I would like is if listed is equal in two aggregations take alerts to order and if alerts the same take detail to order. I hope I explained properly.

Thanks in advance

---

<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:23am UTC](https://discuss.elastic.co/t/search-by-multiple-aggregated-fields-elastic-1-1/18042/2 "2017-07-06T01:23:18Z")

</div>


