# Sorting by .raw fields

**URL:** <https://discuss.elastic.co/t/sorting-by-raw-fields/50076>\
**Category:** Kibana\
**Created:** [May 15, 2016, 3:04pm UTC](https://discuss.elastic.co/t/sorting-by-raw-fields/50076 "2016-05-15T15:04:35Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![haizaar](https://avatars.discourse-cdn.com/v4/letter/h/3d9bf3/32.png) [@haizaar](https://discuss.elastic.co/u/haizaar)\
**Post date:** [May 15, 2016, 3:04pm UTC](https://discuss.elastic.co/t/sorting-by-raw-fields/50076/1 "2016-05-15T15:04:35Z")

</div>

Hi guys,

I'm trying to sort rows in a discover section in Kibana 4.5/ES 2.3.2. I have a `customer_name` field which is analyzed using ngrams, so sorting by it is meaningless. I've added another subfield - `customer_name.raw` which is not analyzed.

Unfortunately this field does not appear under "Discover section" in Kibana.

So what's the Kibana approach for sorting on analyzed fields?

Thanks,  
Zaar

---

<div class="post-metadata">

**Author:** ![LeeDr](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/leedr/32/9289_2.png) [@LeeDr](https://discuss.elastic.co/u/LeeDr)\
**Post date:** [May 16, 2016, 6:28pm UTC](https://discuss.elastic.co/t/sorting-by-raw-fields/50076/2 "2016-05-16T18:28:06Z")

</div>

Hi Zaar,

Kibana only shows the analyzed fields on the discover tab. I think this is because Elasticsearch stores the analyzed fields in an inverted index and can return search results very quickly compared to the unanalyzed field.

But you can still filter results on Discover tab on the unanalyzed raw field. So for example, you can still put `customer_name.raw:"John Smith"` in the search bar.

And the .raw fields are available on the Visualization tab. So you can make a Vertical Bar Chart which looks very similar to the Discover tab and use aggregations on raw fields.

Regards,  
Lee

---

<div class="post-metadata">

**Author:** ![haizaar](https://avatars.discourse-cdn.com/v4/letter/h/3d9bf3/32.png) [@haizaar](https://discuss.elastic.co/u/haizaar)\
**Post date:** [May 17, 2016, 8:00am UTC](https://discuss.elastic.co/t/sorting-by-raw-fields/50076/3 "2016-05-17T08:00:21Z")

</div>

Hi Lee,

Not analyzed fields are stored in inverted index as well. There is no performance consideration here. I'm aware about searching and visualizations, but my question was specifically about **sorting**.

I guess Kibana's problem in Discover is with multifields and not not\_analyzed fields (which are shown BTW).

---

<div class="post-metadata">

**Author:** ![LeeDr](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/leedr/32/9289_2.png) [@LeeDr](https://discuss.elastic.co/u/LeeDr)\
**Post date:** [May 17, 2016, 5:57pm UTC](https://discuss.elastic.co/t/sorting-by-raw-fields/50076/4 "2016-05-17T17:57:44Z")

</div>

This would not be a very user-friendly solution but it looks like you could change the sort field in the URL. For example, in the URL below I could change by current sort on "host" to "host.raw"

`http://localhost:5601/app/kibana#/discover?_g=()&_a=(columns:!(host),filters:!(),index:'logstash-*',interval:auto,query:(query_string:(analyze_wildcard:!t,query:'*')),sort:!(host,desc),vis:(aggs:!((params:(field:referer,orderBy:'2',size:20),schema:segment,type:terms),(id:'2',schema:metric,type:count)),type:histogram))&indexPattern=logstash-*&type=histogram`

I'll look into some other solutions...

---

<div class="post-metadata">

**Author:** ![haizaar](https://avatars.discourse-cdn.com/v4/letter/h/3d9bf3/32.png) [@haizaar](https://discuss.elastic.co/u/haizaar)\
**Post date:** [May 17, 2016, 8:30pm UTC](https://discuss.elastic.co/t/sorting-by-raw-fields/50076/5 "2016-05-17T20:30:02Z")

</div>

Yes, this works, but indeed very geeky as you say. Looks like a candidate for feature request 🙂

---

<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:53pm UTC](https://discuss.elastic.co/t/sorting-by-raw-fields/50076/6 "2017-07-06T13:53:09Z")

</div>


