# Our approach to make custom facet's order

**URL:** <https://discuss.elastic.co/t/our-approach-to-make-custom-facets-order/22131>\
**Category:** Elasticsearch\
**Created:** [February 12, 2015, 11:29am UTC](https://discuss.elastic.co/t/our-approach-to-make-custom-facets-order/22131 "2015-02-12T11:29:13Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![akkurug](https://avatars.discourse-cdn.com/v4/letter/a/df705f/32.png) [@akkurug](https://discuss.elastic.co/u/akkurug)\
**Post date:** [February 12, 2015, 11:29am UTC](https://discuss.elastic.co/t/our-approach-to-make-custom-facets-order/22131/1 "2015-02-12T11:29:13Z")

</div>

Please see below

{  
"aggs": {  
"category": {  
"terms": {  
"field": "category.name",  
"order": {  
"sorting": "asc"  
}  
},  
"aggs": {  
"sorting": {  
"avg": {  
"field": "category.sortCode"  
}  
}  
}  
}  
}  
}

I think it's clear just from short viewing -we add special sorting field  
and then get avg metrics for using at order

It is working -but i am not sure that is the only way or the most effective

Advice please

--  
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/27805892-fb1c-4738-83d6-125f2e5d4212%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/27805892-fb1c-4738-83d6-125f2e5d4212%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, 12:33am UTC](https://discuss.elastic.co/t/our-approach-to-make-custom-facets-order/22131/2 "2017-07-06T00:33:10Z")

</div>


