# Sort field Using Kibana

**URL:** <https://discuss.elastic.co/t/sort-field-using-kibana/25931>\
**Category:** Kibana\
**Created:** [July 20, 2015, 5:31pm UTC](https://discuss.elastic.co/t/sort-field-using-kibana/25931 "2015-07-20T17:31:52Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Aditya\_Patel](https://avatars.discourse-cdn.com/v4/letter/a/3bc359/32.png) [@Aditya\_Patel](https://discuss.elastic.co/u/Aditya_Patel)\
**Post date:** [July 20, 2015, 5:31pm UTC](https://discuss.elastic.co/t/sort-field-using-kibana/25931/1 "2015-07-20T17:31:52Z")

</div>

Hi

I was wondering how to go about sorting one field wrt another field. Suppose we have two fields in our object.  
eg.  
1 {  
id: x1  
val : 3 }  
2{  
id: x2  
val : 4 }  
Can we sort id's as x2,x1 (wrt val in this scenario) in kibana?

Thanks.

---

<div class="post-metadata">

**Author:** ![tbragin](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/tbragin/32/45166_2.png) [@tbragin](https://discuss.elastic.co/u/tbragin)\
**Post date:** [July 20, 2015, 10:37pm UTC](https://discuss.elastic.co/t/sort-field-using-kibana/25931/2 "2015-07-20T22:37:45Z")

</div>

Sure, just add both to a data table and search by either header from there

 ![](https://us1.discourse-cdn.com/elastic/original/2X/4/4faf5fbdac34a7eb4206f40aa6f575f9787b2dc7.png)

---

<div class="post-metadata">

**Author:** ![Aditya\_Patel](https://avatars.discourse-cdn.com/v4/letter/a/3bc359/32.png) [@Aditya\_Patel](https://discuss.elastic.co/u/Aditya_Patel)\
**Post date:** [July 21, 2015, 9:24am UTC](https://discuss.elastic.co/t/sort-field-using-kibana/25931/3 "2015-07-21T09:24:52Z")

</div>

Thanks it worked !

---

<div class="post-metadata">

**Author:** ![Aditya\_Patel](https://avatars.discourse-cdn.com/v4/letter/a/3bc359/32.png) [@Aditya\_Patel](https://discuss.elastic.co/u/Aditya_Patel)\
**Post date:** [July 21, 2015, 12:13pm UTC](https://discuss.elastic.co/t/sort-field-using-kibana/25931/4 "2015-07-21T12:13:20Z")

</div>

Also if i want metric but by a query in elasticsearch , how would i go about it.

I tried following query but it's throwing an error.

GET /index/table/\_search/  
{  
"sort": [  
{  
"x1": {"order" : "asc"}  
}  
],  
"query": {  
"term": { "id" }  
},  
}

Thanks in advance

---

<div class="post-metadata">

**Author:** ![tbragin](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/tbragin/32/45166_2.png) [@tbragin](https://discuss.elastic.co/u/tbragin)\
**Post date:** [July 21, 2015, 1:41pm UTC](https://discuss.elastic.co/t/sort-field-using-kibana/25931/5 "2015-07-21T13:41:14Z")

</div>

All aggregations and sorting are configured via the visual builder in the UI. The search bar can accept query DSL for the purposes of filtering the documents, but only the query/filter part of the DSL.

Check out this thread for such an example: [Where to add a missing filter in this Kibana search](https://discuss.elastic.co/t/where-to-add-a-missing-filter-in-this-kibana-search/24845/2)

---

<div class="post-metadata">

**Author:** ![Aditya\_Patel](https://avatars.discourse-cdn.com/v4/letter/a/3bc359/32.png) [@Aditya\_Patel](https://discuss.elastic.co/u/Aditya_Patel)\
**Post date:** [July 22, 2015, 6:29am UTC](https://discuss.elastic.co/t/sort-field-using-kibana/25931/6 "2015-07-22T06:29:05Z")

</div>

Thanks. Currently i want to port either the dashboard completely to my website or get the metric table data from the elasticsearch via query , aggregation (I am not sure which needs to be used), so i can use it.

Thanks again for the patience and help. 😊

---

<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, 2:16pm UTC](https://discuss.elastic.co/t/sort-field-using-kibana/25931/7 "2017-07-06T14:16:04Z")

</div>


