# Mapping, Searching, Ordering

**URL:** <https://discuss.elastic.co/t/mapping-searching-ordering/4153>\
**Category:** Elasticsearch\
**Created:** [March 24, 2011, 4:26am UTC](https://discuss.elastic.co/t/mapping-searching-ordering/4153 "2011-03-24T04:26:48Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Nathan\_Ekstrom](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nathan_ekstrom/32/3249_2.png) [@Nathan\_Ekstrom](https://discuss.elastic.co/u/Nathan_Ekstrom)\
**Post date:** [March 24, 2011, 4:26am UTC](https://discuss.elastic.co/t/mapping-searching-ordering/4153/1 "2011-03-24T04:26:48Z")

</div>

I'm new to elasticsearch and lucene and am rather confused on a couple of  
points.

First when creating a mapping what does the option "index" with either a  
value of "analyzed" or "not\_analyzed" do? How does it affect the index.  
Next I have the following mapping. Below are just the properties

{  
'path': {  
"type": "multi\_field",  
"fields": {  
"path": {"type": "string", "index": "not\_analyzed"},  
"sub\_path": {"type": "string", "index": "not\_analyzed"},  
"name": {"type": "string", "index": "not\_analyzed"},  
"extension": {"type": "string", "index": "not\_analyzed"},  
},  
},  
'owner': {  
"type": "multi\_field",  
"fields": {  
"owner": {"type": "integer", "index": "analyzed"},  
"name": {"type": "string", "index": "not\_analyzed"},  
},  
},  
'data\_store': {  
"type": "integer",  
"index": "analyzed",  
},  
'size': {  
"type": "integer",  
"index": "analyzed",  
},  
'sharing': {  
"type": "object",  
"properties": {  
"name": {"type": "string", "index": "not\_analyzed"},  
"id": {"type": "integer", "index": "analyzed"},  
"permission": {"type": "integer", "index": "analyzed"},  
},  
},  
}

When I try to sort on path or path.sub\_path it throws an error saying,

"java.io.IOException: Can't sort on string types with more than one value  
per doc, or more than one token per field"

path.sub\_path is an array of strings but path is just a string. I don't  
understand what I'm doing wrong. If I try to sort on size it doesn't throw  
an error but doesn't sort it either.

My sort looks like

[{"size": {"order": "desc"},},] \<--- Doesn't throw an error but doesn't sort  
either

[{"path": {"order":"desc"},},] \<--- Causes the error to be thrown

Any advice or help is appreciated. I've tried reading the docs but I feel  
like I'm missing some foundational pieces that would explain this. So if  
there are any blog posts or articles covering basics/foundations that  
someone can point me to I would appreciate it.

Thanks,

Nathan

---

<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:** [March 24, 2011, 10:28am UTC](https://discuss.elastic.co/t/mapping-searching-ordering/4153/2 "2011-03-24T10:28:32Z")

</div>

The fact that path.sub\_path is an array of values, means it has more than one value, and you can't sort on a field with more than one value.

Its the same thing with analyzed, if the analysis process generates more than one token for a field, then it has several values.

The analyze option of index means that the field will be tokenized into tokens and one will be able to search on its tokenized form. This is how search engines work, you take text, break it down into tokens, and then you can search across those tokens. This process is the analysis process of a field. If you specify the field as not\_analyzed, it means that the field will be indexed and searchable, but, it will not be tokenized, and its value will be considered as a single token.  
On Thursday, March 24, 2011 at 6:26 AM, Nathan Ekstrom wrote:

> I'm new to elasticsearch and lucene and am rather confused on a couple of points.
> 
> First when creating a mapping what does the option "index" with either a value of "analyzed" or "not\_analyzed" do? How does it affect the index. Next I have the following mapping. Below are just the properties
> 
> {  
> 'path': {  
> "type": "multi\_field",  
> "fields": {  
> "path": {"type": "string", "index": "not\_analyzed"},  
> "sub\_path": {"type": "string", "index": "not\_analyzed"},  
> "name": {"type": "string", "index": "not\_analyzed"},  
> "extension": {"type": "string", "index": "not\_analyzed"},  
> },  
> },  
> 'owner': {  
> "type": "multi\_field",  
> "fields": {  
> "owner": {"type": "integer", "index": "analyzed"},  
> "name": {"type": "string", "index": "not\_analyzed"},  
> },  
> },  
> 'data\_store': {  
> "type": "integer",  
> "index": "analyzed",  
> },  
> 'size': {  
> "type": "integer",  
> "index": "analyzed",  
> },  
> 'sharing': {  
> "type": "object",  
> "properties": {  
> "name": {"type": "string", "index": "not\_analyzed"},  
> "id": {"type": "integer", "index": "analyzed"},  
> "permission": {"type": "integer", "index": "analyzed"},  
> },  
> },  
> }
> 
> When I try to sort on path or path.sub\_path it throws an error saying,
> 
> "java.io.IOException: Can't sort on string types with more than one value per doc, or more than one token per field"
> 
> path.sub\_path is an array of strings but path is just a string. I don't understand what I'm doing wrong. If I try to sort on size it doesn't throw an error but doesn't sort it either.
> 
> My sort looks like
> 
> [{"size": {"order": "desc"},},] \<--- Doesn't throw an error but doesn't sort either
> 
> [{"path": {"order":"desc"},},] \<--- Causes the error to be thrown
> 
> Any advice or help is appreciated. I've tried reading the docs but I feel like I'm missing some foundational pieces that would explain this. So if there are any blog posts or articles covering basics/foundations that someone can point me to I would appreciate it.
> 
> Thanks,
> 
> Nathan

---

<div class="post-metadata">

**Author:** ![Nathan\_Ekstrom](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nathan_ekstrom/32/3249_2.png) [@Nathan\_Ekstrom](https://discuss.elastic.co/u/Nathan_Ekstrom)\
**Post date:** [March 25, 2011, 8:29pm UTC](https://discuss.elastic.co/t/mapping-searching-ordering/4153/3 "2011-03-25T20:29:12Z")

</div>

So to sort on a string it needs to be not\_analyzed and not an array. For  
others who may have the same question I found this helped  
[ConceptsAndDefinitions - Apache Lucene (Java) - Apache Software Foundation](http://wiki.apache.org/lucene-java/ConceptsAndDefinitions).

Thanks,

Nathan

On Thu, Mar 24, 2011 at 4:28 AM, Shay Banon [shay.banon@elasticsearch.com](mailto:shay.banon@elasticsearch.com)wrote:

> The fact that path.sub\_path is an array of values, means it has more than  
> one value, and you can't sort on a field with more than one value.
> 
> Its the same thing with analyzed, if the analysis process generates more  
> than one token for a field, then it has several values.
> 
> The analyze option of index means that the field will be tokenized into  
> tokens and one will be able to search on its tokenized form. This is how  
> search engines work, you take text, break it down into tokens, and then you  
> can search across those tokens. This process is the analysis process of a  
> field. If you specify the field as not\_analyzed, it means that the field  
> will be indexed and searchable, but, it will not be tokenized, and its value  
> will be considered as a single token.
> 
> On Thursday, March 24, 2011 at 6:26 AM, Nathan Ekstrom wrote:
> 
> I'm new to elasticsearch and lucene and am rather confused on a couple of  
> points.
> 
> First when creating a mapping what does the option "index" with either a  
> value of "analyzed" or "not\_analyzed" do? How does it affect the index.  
> Next I have the following mapping. Below are just the properties
> 
> {  
> 'path': {  
> "type": "multi\_field",  
> "fields": {  
> "path": {"type": "string", "index": "not\_analyzed"},  
> "sub\_path": {"type": "string", "index": "not\_analyzed"},  
> "name": {"type": "string", "index": "not\_analyzed"},  
> "extension": {"type": "string", "index": "not\_analyzed"},  
> },  
> },  
> 'owner': {  
> "type": "multi\_field",  
> "fields": {  
> "owner": {"type": "integer", "index": "analyzed"},  
> "name": {"type": "string", "index": "not\_analyzed"},  
> },  
> },  
> 'data\_store': {  
> "type": "integer",  
> "index": "analyzed",  
> },  
> 'size': {  
> "type": "integer",  
> "index": "analyzed",  
> },  
> 'sharing': {  
> "type": "object",  
> "properties": {  
> "name": {"type": "string", "index": "not\_analyzed"},  
> "id": {"type": "integer", "index": "analyzed"},  
> "permission": {"type": "integer", "index": "analyzed"},  
> },  
> },  
> }
> 
> When I try to sort on path or path.sub\_path it throws an error saying,
> 
> "java.io.IOException: Can't sort on string types with more than one value  
> per doc, or more than one token per field"
> 
> path.sub\_path is an array of strings but path is just a string. I don't  
> understand what I'm doing wrong. If I try to sort on size it doesn't throw  
> an error but doesn't sort it either.
> 
> My sort looks like
> 
> [{"size": {"order": "desc"},},] \<--- Doesn't throw an error but doesn't  
> sort either
> 
> [{"path": {"order":"desc"},},] \<--- Causes the error to be thrown
> 
> Any advice or help is appreciated. I've tried reading the docs but I feel  
> like I'm missing some foundational pieces that would explain this. So if  
> there are any blog posts or articles covering basics/foundations that  
> someone can point me to I would appreciate it.
> 
> Thanks,
> 
> Nathan

---

<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:09am UTC](https://discuss.elastic.co/t/mapping-searching-ordering/4153/4 "2017-07-06T04:09:14Z")

</div>


