# Sorting weirdness

**URL:** <https://discuss.elastic.co/t/sorting-weirdness/20431>\
**Category:** Elasticsearch\
**Created:** [October 25, 2014, 6:37pm UTC](https://discuss.elastic.co/t/sorting-weirdness/20431 "2014-10-25T18:37:28Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Michael\_Irwin](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/michael_irwin/32/985_2.png) [@Michael\_Irwin](https://discuss.elastic.co/u/Michael_Irwin)\
**Post date:** [October 25, 2014, 6:37pm UTC](https://discuss.elastic.co/t/sorting-weirdness/20431/1 "2014-10-25T18:37:28Z")

</div>

I have a mapping like this:

```
    "venue": {
      "type": "nested",
      "include_in_parent": true,
      "properties": {
        "name": {
          "type": "string"
        }
      }

```

If I'm sorting by 'venue.name' ascending, why would a name like 'Terminal  
5' be sorted before 'B.B. King Blues Club & Grill'? Does it have something  
to do with the number '5' in the name?

--  
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/159fe507-bb01-4504-9ba7-e6b7e7bb964c%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/159fe507-bb01-4504-9ba7-e6b7e7bb964c%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![jpountz](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jpountz/32/45836_2.png) [@jpountz](https://discuss.elastic.co/u/jpountz)\
**Post date:** [October 27, 2014, 5:18pm UTC](https://discuss.elastic.co/t/sorting-weirdness/20431/2 "2014-10-27T17:18:28Z")

</div>

Hi Michael,

This is because your field is tokenized and elasticsearch will take the  
minimum value as a sort value. For the first document, this would be "5",  
which compares lower than "B" in the second string. To make it work as  
expected, you need to index your field as `not_analyzed` (

> **[Elasticsearch Platform — Find real-time answers at scale](https://www.elastic.co)**
>
> Power insights and outcomes with the Elasticsearch Platform and AI. See into your data and find answers that matter with enterprise solutions designed to help you build, observe, and protect. Try Elasticsearch free today.

).

On Sat, Oct 25, 2014 at 8:37 PM, Michael Irwin [mdi@livej.am](mailto:mdi@livej.am) wrote:

> I have a mapping like this:
> 
> ```
> "venue": {
> "type": "nested",
> "include_in_parent": true,
> "properties": {
> "name": {
> "type": "string"
> }
> }
> 
> ```
> 
> If I'm sorting by 'venue.name' ascending, why would a name like 'Terminal  
> 5' be sorted before 'B.B. King Blues Club & Grill'? Does it have  
> something to do with the number '5' in the name?
> 
> --  
> 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/159fe507-bb01-4504-9ba7-e6b7e7bb964c%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/159fe507-bb01-4504-9ba7-e6b7e7bb964c%40googlegroups.com)  
> [https://groups.google.com/d/msgid/elasticsearch/159fe507-bb01-4504-9ba7-e6b7e7bb964c%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/159fe507-bb01-4504-9ba7-e6b7e7bb964c%40googlegroups.com?utm_medium=email&utm_source=footer)  
> .  
> For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

--  
Adrien Grand

--  
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/CAL6Z4j6eGjjezKR592k7\_8WUf151j\_CxE7aR%2BuMrB0Fgo8U-HA%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAL6Z4j6eGjjezKR592k7_8WUf151j_CxE7aR%2BuMrB0Fgo8U-HA%40mail.gmail.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:53am UTC](https://discuss.elastic.co/t/sorting-weirdness/20431/3 "2017-07-06T00:53:39Z")

</div>

Closed on July 6, 2017, 12:53am UTC


