# Problem with sorting using an analyzed field

**URL:** <https://discuss.elastic.co/t/problem-with-sorting-using-an-analyzed-field/3877>\
**Category:** Elasticsearch\
**Created:** [February 3, 2011, 2:53pm UTC](https://discuss.elastic.co/t/problem-with-sorting-using-an-analyzed-field/3877 "2011-02-03T14:53:29Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Enrique\_Medina\_Monte](https://avatars.discourse-cdn.com/v4/letter/e/4491bb/32.png) [@Enrique\_Medina\_Monte](https://discuss.elastic.co/u/Enrique_Medina_Monte)\
**Post date:** [February 3, 2011, 2:53pm UTC](https://discuss.elastic.co/t/problem-with-sorting-using-an-analyzed-field/3877/1 "2011-02-03T14:53:29Z")

</div>

Hi,

Why cannot I sort by a field which is analyzed? It should make sense to  
analyze a "name" field to index products and also be able to sort by "name"  
when getting the search results, agree?

{

```
"from" : 0, size: 100,

```

"sort" : { "nombre" : "desc" },

```
"query" : {

```

"fuzzy" : { "nombre" : "lacie", "descripcion" : "lacie" }

```
}

```

}

I get the error:

sort[\<custom:"nombre":  
org.elasticsearch.index.field.data.strings.StringFieldDataType$1@46176578\>  
!]: Query Failed [Failed to execute main query]]; nested: IOException[Can't  
sort on string types with more than one value per doc, or more than one  
token per field]; }]"}]

Thanks.

---

<div class="post-metadata">

**Author:** ![kimchy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kimchy/32/44952_2.png) [@kimchy](https://discuss.elastic.co/u/kimchy)\
**Post date:** [February 3, 2011, 10:51pm UTC](https://discuss.elastic.co/t/problem-with-sorting-using-an-analyzed-field/3877/2 "2011-02-03T22:51:50Z")

</div>

You can use multi field mapping, with the "original" being analyzed, and one named "sortable" to have it not\_analyzed.  
On Thursday, February 3, 2011 at 4:53 PM, Enrique Medina Montenegro wrote:

> Hi,
> 
> Why cannot I sort by a field which is analyzed? It should make sense to analyze a "name" field to index products and also be able to sort by "name" when getting the search results, agree?
> 
> {  
> "from" : 0, size: 100,  
> "sort" : { "nombre" : "desc" },  
> "query" : {  
> "fuzzy" : { "nombre" : "lacie", "descripcion" : "lacie" }  
> }  
> }
> 
> I get the error:
> 
> sort[\<custom:"nombre": org.elasticsearch.index.field.data.strings.StringFieldDataType$1@46176578\>!]: Query Failed [Failed to execute main query]]; nested: IOException[Can't sort on string types with more than one value per doc, or more than one token per field]; }]"}]
> 
> Thanks.

---

<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, 4:12am UTC](https://discuss.elastic.co/t/problem-with-sorting-using-an-analyzed-field/3877/3 "2017-07-06T04:12:38Z")

</div>


