# Can't sort on string types with more than one value per doc

**URL:** <https://discuss.elastic.co/t/cant-sort-on-string-types-with-more-than-one-value-per-doc/4887>\
**Category:** Elasticsearch\
**Created:** [July 18, 2011, 8:49pm UTC](https://discuss.elastic.co/t/cant-sort-on-string-types-with-more-than-one-value-per-doc/4887 "2011-07-18T20:49:12Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![cgascon](https://avatars.discourse-cdn.com/v4/letter/c/59ef9b/32.png) [@cgascon](https://discuss.elastic.co/u/cgascon)\
**Post date:** [July 18, 2011, 8:49pm UTC](https://discuss.elastic.co/t/cant-sort-on-string-types-with-more-than-one-value-per-doc/4887/1 "2011-07-18T20:49:12Z")

</div>

Hi,

I'm trying to sort documents based on a field named "sortableSubject" (not  
analyzed, type string).

But even though it's not analyzed, it throws the following exception:

"ReduceSearchPhaseException: Failed to execute phase [fetch], [reduce] ;  
shardFailures {[1][1][4]: QueryPhaseExecutionException[[1][4]:  
query[+(body:body\* |  
subject:body\*)],from[0],size[5000],sort[\<custom:"sortableSubject":  
org.elasticsearch.index.field.data.strings.StringFieldDataType$1@14637eb\>!]:  
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]; }{[1][1][0]: QueryPhaseExecutionException[[1][0]: query[+(body:body\*  
|  
subject:body\*)],from[0],size[5000],sort[\<custom:"sortableSubject":  
org.elasticsearch.index.field.data.strings.StringFieldDataType$1@1b72b99\>!]:  
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]; }{[1][1][3]: QueryPhaseExecutionException[[1][3]: query[+(body:body\*  
|  
subject:body\*)],from[0],size[5000],sort[\<custom:"sortableSubject":  
org.elasticsearch.index.field.data.strings.StringFieldDataType$1@547ea3\>!]:  
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]; }{[1][1][1]: QueryPhaseExecutionException[[1][1]: query[+(body:body\*  
|  
subject:body\*)],from[0],size[5000],sort[\<custom:"sortableSubject":  
org.elasticsearch.index.field.data.strings.StringFieldDataType$1@8f7cf4\>!]:  
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]; }{[1][1][2]: QueryPhaseExecutionException[[1][2]: query[+(body:body\*  
|  
subject:body\*)],from[0],size[5000],sort[\<custom:"sortableSubject":  
org.elasticsearch.index.field.data.strings.StringFieldDataType$1@1015d59\>!]:  
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]; }

Am I missing something ? Can't we sort documents on string of many words ?

--  
View this message in context: [http://elasticsearch-users.115913.n3.nabble.com/Can-t-sort-on-string-types-with-more-than-one-value-per-doc-tp3180532p3180532.html](http://elasticsearch-users.115913.n3.nabble.com/Can-t-sort-on-string-types-with-more-than-one-value-per-doc-tp3180532p3180532.html)  
Sent from the ElasticSearch Users mailing list archive at [Nabble.com](http://Nabble.com).

---

<div class="post-metadata">

**Author:** ![Karussell1](https://avatars.discourse-cdn.com/v4/letter/k/50afbb/32.png) [@Karussell1](https://discuss.elastic.co/u/Karussell1)\
**Post date:** [July 20, 2011, 8:11am UTC](https://discuss.elastic.co/t/cant-sort-on-string-types-with-more-than-one-value-per-doc/4887/2 "2011-07-20T08:11:16Z")

</div>

Are you sure its not analyzed? (try a get mapping request)  
Are there multiple values - e.g. an array of sortableSubject?

On 18 Jul., 22:49, icefire [gascon.char...@gmail.com](mailto:gascon.char...@gmail.com) wrote:

> Hi,
> 
> I'm trying to sort documents based on a field named "sortableSubject" (not  
> analyzed, type string).
> 
> But even though it's not analyzed, it throws the following exception:
> 
> "ReduceSearchPhaseException: Failed to execute phase [fetch], [reduce] ;  
> shardFailures {[1][1][4]: QueryPhaseExecutionException[[1][4]:  
> query[+(body:body\* |  
> subject:body\*)],from[0],size[5000],sort[\<custom:"sortableSubject":  
> org.elasticsearch.index.field.data.strings.StringFieldDataType$1@14637eb\>!]:  
> 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]; }{[1][1][0]: QueryPhaseExecutionException[[1][0]: query[+(body:body\*  
> |  
> subject:body\*)],from[0],size[5000],sort[\<custom:"sortableSubject":  
> org.elasticsearch.index.field.data.strings.StringFieldDataType$1@1b72b99\>!]:  
> 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]; }{[1][1][3]: QueryPhaseExecutionException[[1][3]: query[+(body:body\*  
> |  
> subject:body\*)],from[0],size[5000],sort[\<custom:"sortableSubject":  
> org.elasticsearch.index.field.data.strings.StringFieldDataType$1@547ea3\>!]:  
> 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]; }{[1][1][1]: QueryPhaseExecutionException[[1][1]: query[+(body:body\*  
> |  
> subject:body\*)],from[0],size[5000],sort[\<custom:"sortableSubject":  
> org.elasticsearch.index.field.data.strings.StringFieldDataType$1@8f7cf4\>!]:  
> 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]; }{[1][1][2]: QueryPhaseExecutionException[[1][2]: query[+(body:body\*  
> |  
> subject:body\*)],from[0],size[5000],sort[\<custom:"sortableSubject":  
> org.elasticsearch.index.field.data.strings.StringFieldDataType$1@1015d59\>!]:  
> 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]; }
> 
> Am I missing something ? Can't we sort documents on string of many words ?
> 
> --  
> View this message in context:[http://elasticsearch-users.115913.n3.nabble.com/Can-t-sort-on-string-](http://elasticsearch-users.115913.n3.nabble.com/Can-t-sort-on-string-)...  
> Sent from the Elasticsearch Users mailing list archive at [Nabble.com](http://Nabble.com).

---

<div class="post-metadata">

**Author:** ![jmurdoch](https://avatars.discourse-cdn.com/v4/letter/j/3be4f8/32.png) [@jmurdoch](https://discuss.elastic.co/u/jmurdoch)\
**Post date:** [July 20, 2011, 6:13pm UTC](https://discuss.elastic.co/t/cant-sort-on-string-types-with-more-than-one-value-per-doc/4887/3 "2011-07-20T18:13:55Z")

</div>

I have come across this in 0.17.0 as well, and its somewhat inconvenient for my purposes as well. I guess there is not yet a way to make a multi-token string field both analyzed _and_ sortable? (I guess this would require a new 'sortable' field mapping option). I really like having cake, but I really like to eat it too 🙂

---

<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 24, 2011, 2:19am UTC](https://discuss.elastic.co/t/cant-sort-on-string-types-with-more-than-one-value-per-doc/4887/4 "2011-07-24T02:19:08Z")

</div>

There is with the multi field option, or are you pointing to something else?

On Wed, Jul 20, 2011 at 9:13 PM, jmurdoch [jv.murdoch@gmail.com](mailto:jv.murdoch@gmail.com) wrote:

> I have come across this in 0.17.0 as well, and its somewhat inconvenient  
> for  
> my purposes as well. I guess there is not yet a way to make a multi-token  
> string field both analyzed _and_ sortable? (I guess this would require a  
> new 'sortable' field mapping option). I really like having cake, but I  
> really like to eat it too 🙂
> 
> --  
> View this message in context:  
> [http://elasticsearch-users.115913.n3.nabble.com/Can-t-sort-on-string-types-with-more-than-one-value-per-doc-tp3183742p3186225.html](http://elasticsearch-users.115913.n3.nabble.com/Can-t-sort-on-string-types-with-more-than-one-value-per-doc-tp3183742p3186225.html)  
> Sent from the Elasticsearch Users mailing list archive at [Nabble.com](http://Nabble.com).

---

<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, 3:59am UTC](https://discuss.elastic.co/t/cant-sort-on-string-types-with-more-than-one-value-per-doc/4887/5 "2017-07-06T03:59:41Z")

</div>


