# Sorting failing in latest master

**URL:** https://discuss.elastic.co/t/sorting-failing-in-latest-master/3105
**Category:** Elasticsearch
**Created:** [July 14, 2010, 11:18pm UTC](https://discuss.elastic.co/t/sorting-failing-in-latest-master/3105 "2010-07-14T23:18:01Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![Samuel\_Doyle](https://avatars.discourse-cdn.com/v4/letter/s/e19adc/32.png) [@Samuel\_Doyle](https://discuss.elastic.co/u/Samuel_Doyle)
#### Post date: [July 14, 2010, 11:18pm UTC](https://discuss.elastic.co/t/sorting-failing-in-latest-master/3105/1 "2010-07-14T23:18:01Z")

</div>

I am now seeing failures in my search when sorting. I have not made any  
changes to my code or data which had worked previously.

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]; ]

is this something new?

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: [July 14, 2010, 11:20pm UTC](https://discuss.elastic.co/t/sorting-failing-in-latest-master/3105/2 "2010-07-14T23:20:31Z")

</div>

Are you sorting on an analyzed field or a field that has several values  
within a document?

-shay.banon

On Thu, Jul 15, 2010 at 2:18 AM, Samuel Doyle [samueldoyle@gmail.com](mailto:samueldoyle@gmail.com) wrote:

> I am now seeing failures in my search when sorting. I have not made any  
> changes to my code or data which had worked previously.
> 
> 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]; ]
> 
> is this something new?
> 
> Thanks

---

<div class="post-metadata">

### Author: ![Samuel\_Doyle](https://avatars.discourse-cdn.com/v4/letter/s/e19adc/32.png) [@Samuel\_Doyle](https://discuss.elastic.co/u/Samuel_Doyle)
#### Post date: [July 14, 2010, 11:26pm UTC](https://discuss.elastic.co/t/sorting-failing-in-latest-master/3105/3 "2010-07-14T23:26:49Z")

</div>

It is actually a lastname field and it is analyzed although it probably  
should not be.  
It did work before however.

On Wed, Jul 14, 2010 at 4:20 PM, Shay Banon [shay.banon@elasticsearch.com](mailto:shay.banon@elasticsearch.com)wrote:

> Are you sorting on an analyzed field or a field that has several values  
> within a document?
> 
> -shay.banon
> 
> On Thu, Jul 15, 2010 at 2:18 AM, Samuel Doyle [samueldoyle@gmail.com](mailto:samueldoyle@gmail.com)wrote:
> 
> > I am now seeing failures in my search when sorting. I have not made any  
> > changes to my code or data which had worked previously.
> > 
> > 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]; ]
> > 
> > is this something new?
> > 
> > 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: [July 14, 2010, 11:34pm UTC](https://discuss.elastic.co/t/sorting-failing-in-latest-master/3105/4 "2010-07-14T23:34:40Z")

</div>

It might have worked before (it actually depends on the Lucene version when  
it worked), but, it does not make sense to sort on a field that is analyzed.  
So, either use a multi\_field mapping, and add another mapping for last\_name  
that is not analyzed (and name it something like lastNameSortable), or have  
the actual last name not analyzed.

-shay.banon

On Thu, Jul 15, 2010 at 2:26 AM, Samuel Doyle [samueldoyle@gmail.com](mailto:samueldoyle@gmail.com) wrote:

> It is actually a lastname field and it is analyzed although it probably  
> should not be.  
> It did work before however.
> 
> On Wed, Jul 14, 2010 at 4:20 PM, Shay Banon [shay.banon@elasticsearch.com](mailto:shay.banon@elasticsearch.com)wrote:
> 
> > Are you sorting on an analyzed field or a field that has several values  
> > within a document?
> > 
> > -shay.banon
> > 
> > On Thu, Jul 15, 2010 at 2:18 AM, Samuel Doyle [samueldoyle@gmail.com](mailto:samueldoyle@gmail.com)wrote:
> > 
> > > I am now seeing failures in my search when sorting. I have not made any  
> > > changes to my code or data which had worked previously.
> > > 
> > > 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]; ]
> > > 
> > > is this something new?
> > > 
> > > Thanks

---

<div class="post-metadata">

### Author: ![Samuel\_Doyle](https://avatars.discourse-cdn.com/v4/letter/s/e19adc/32.png) [@Samuel\_Doyle](https://discuss.elastic.co/u/Samuel_Doyle)
#### Post date: [July 14, 2010, 11:35pm UTC](https://discuss.elastic.co/t/sorting-failing-in-latest-master/3105/5 "2010-07-14T23:35:52Z")

</div>

Cool, thanks!

S.D.

On Wed, Jul 14, 2010 at 4:34 PM, Shay Banon [shay.banon@elasticsearch.com](mailto:shay.banon@elasticsearch.com)wrote:

> It might have worked before (it actually depends on the Lucene version when  
> it worked), but, it does not make sense to sort on a field that is analyzed.  
> So, either use a multi\_field mapping, and add another mapping for last\_name  
> that is not analyzed (and name it something like lastNameSortable), or have  
> the actual last name not analyzed.
> 
> -shay.banon
> 
> On Thu, Jul 15, 2010 at 2:26 AM, Samuel Doyle [samueldoyle@gmail.com](mailto:samueldoyle@gmail.com)wrote:
> 
> > It is actually a lastname field and it is analyzed although it probably  
> > should not be.  
> > It did work before however.
> > 
> > On Wed, Jul 14, 2010 at 4:20 PM, Shay Banon \<[shay.banon@elasticsearch.com](mailto:shay.banon@elasticsearch.com)
> > 
> > > wrote:
> > 
> > > Are you sorting on an analyzed field or a field that has several values  
> > > within a document?
> > > 
> > > -shay.banon
> > > 
> > > On Thu, Jul 15, 2010 at 2:18 AM, Samuel Doyle [samueldoyle@gmail.com](mailto:samueldoyle@gmail.com)wrote:
> > > 
> > > > I am now seeing failures in my search when sorting. I have not made any  
> > > > changes to my code or data which had worked previously.
> > > > 
> > > > 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]; ]
> > > > 
> > > > is this something new?
> > > > 
> > > > 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: [July 14, 2010, 11:41pm UTC](https://discuss.elastic.co/t/sorting-failing-in-latest-master/3105/6 "2010-07-14T23:41:54Z")

</div>

Just to explain a bit more, what you ended up with when sorting on a field  
that is analyzed (on recent Lucene version, before it was throwing a similar  
exception) is just sorting on the first term that got tokenized from the  
field. Many times its not really what you want.

I have reimplemented sorting in 0.9 (so it uses the same data facets use,  
and script fields) for better memory management, and currently its easier  
for me to simply throw an exception in this case. I might revisit this  
decision later on and allow to sort on fields that have multiple terms, but  
it will still only use the first term, which, as mentioned above, does not  
make sense most of the times.

-shay.banon

On Thu, Jul 15, 2010 at 2:35 AM, Samuel Doyle [samueldoyle@gmail.com](mailto:samueldoyle@gmail.com) wrote:

> Cool, thanks!
> 
> S.D.
> 
> On Wed, Jul 14, 2010 at 4:34 PM, Shay Banon [shay.banon@elasticsearch.com](mailto:shay.banon@elasticsearch.com)wrote:
> 
> > It might have worked before (it actually depends on the Lucene version  
> > when it worked), but, it does not make sense to sort on a field that is  
> > analyzed. So, either use a multi\_field mapping, and add another mapping for  
> > last\_name that is not analyzed (and name it something like  
> > lastNameSortable), or have the actual last name not analyzed.
> > 
> > -shay.banon
> > 
> > On Thu, Jul 15, 2010 at 2:26 AM, Samuel Doyle [samueldoyle@gmail.com](mailto:samueldoyle@gmail.com)wrote:
> > 
> > > It is actually a lastname field and it is analyzed although it probably  
> > > should not be.  
> > > It did work before however.
> > > 
> > > On Wed, Jul 14, 2010 at 4:20 PM, Shay Banon \<  
> > > [shay.banon@elasticsearch.com](mailto:shay.banon@elasticsearch.com)\> wrote:
> > > 
> > > > Are you sorting on an analyzed field or a field that has several values  
> > > > within a document?
> > > > 
> > > > -shay.banon
> > > > 
> > > > On Thu, Jul 15, 2010 at 2:18 AM, Samuel Doyle [samueldoyle@gmail.com](mailto:samueldoyle@gmail.com)wrote:
> > > > 
> > > > > I am now seeing failures in my search when sorting. I have not made any  
> > > > > changes to my code or data which had worked previously.
> > > > > 
> > > > > 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]; ]
> > > > > 
> > > > > is this something new?
> > > > > 
> > > > > 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:22am UTC](https://discuss.elastic.co/t/sorting-failing-in-latest-master/3105/7 "2017-07-06T04:22:11Z")

</div>


