# Cannot set string type to analyzed

**URL:** <https://discuss.elastic.co/t/cannot-set-string-type-to-analyzed/14914>\
**Category:** Elasticsearch\
**Created:** [December 17, 2013, 3:10pm UTC](https://discuss.elastic.co/t/cannot-set-string-type-to-analyzed/14914 "2013-12-17T15:10:58Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Thomas\_Bolis](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/thomas_bolis/32/700_2.png) [@Thomas\_Bolis](https://discuss.elastic.co/u/Thomas_Bolis)\
**Post date:** [December 17, 2013, 3:10pm UTC](https://discuss.elastic.co/t/cannot-set-string-type-to-analyzed/14914/1 "2013-12-17T15:10:58Z")

</div>

Hi,

I'm trying to create a mapping for a nested document and I realize that i  
cannot set the index type of a string field to analyzed:

{  
"action": {  
"\_all": {  
"enabled": false  
},  
"\_type": {  
"index": "no"  
},  
"\_timestamp": {  
"enabled": true,  
"store": "yes"  
},  
"\_routing": {  
"required": true,  
"path": "userId"  
},  
"properties": {  
"userId": {  
"type": "string",  
"index": "not\_analyzed"  
},  
"extra": {  
"type": "nested",  
"properties": {  
"key": {  
"type": "string",  
"index": "not\_analyzed"  
},  
_"value": {_

- "type": "string",\*
- "index": "analyzed"\*
- }\*  
}  
}  
}  
}  
}

The above ends up with the following result when calling for the mapping  
(curl -XGET localhost:9200/my\_index/action/\_mapping?pretty ):

{  
"action": {  
"\_all": {  
"enabled": false  
},  
"\_type": {  
"index": "no"  
},  
"\_timestamp": {  
"enabled": true,  
"store": "yes"  
},  
"\_routing": {  
"required": true,  
"path": "userId"  
},  
"properties": {  
"userId": {  
"type" : "string",  
"index" : "not\_analyzed",  
"omit\_norms" : true,  
"index\_options" : "docs"  
},  
"extra": {  
"type": "nested",  
"properties": {  
"key": {  
"type" : "string",  
"index" : "not\_analyzed",  
"omit\_norms" : true,  
"index\_options" : "docs"  
},  
_"value": {_

- "type": "string"\*
- }\*  
}  
}  
}  
}  
}

Should it display index type as analyzed? furthermore I cannot search based  
on this field? Should I search by defining the analyzer?

ES version 0.90.7 but i noticed this since version 0.90.2, probably I'm  
doing something wrong here.

Looking forward for your reply  
Thank you

--  
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/01ec164d-bb31-4e5b-87d2-1a9abadb0b69%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/01ec164d-bb31-4e5b-87d2-1a9abadb0b69%40googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [December 17, 2013, 3:21pm UTC](https://discuss.elastic.co/t/cannot-set-string-type-to-analyzed/14914/2 "2013-12-17T15:21:50Z")

</div>

Hi Thomas,

I guess it could be because "index":"analyzed" is a default value so basically you don't have to set it???

About your search concern, a curl recreation would help a lot to understand what you are actually doing.  
Could you gist it?

--  
David Pilato | Technical Advocate | [Elasticsearch.com](http://Elasticsearch.com)  
@dadoonet | @elasticsearchfr

Le 17 décembre 2013 at 16:11:03, Thomas ([thomas.bolis@gmail.com](mailto:thomas.bolis@gmail.com)) a écrit:

Hi,

I'm trying to create a mapping for a nested document and I realize that i cannot set the index type of a string field to analyzed:

{  
"action": {  
"\_all": {  
"enabled": false  
},  
"\_type": {  
"index": "no"  
},  
"\_timestamp": {  
"enabled": true,  
"store": "yes"  
},  
"\_routing": {  
"required": true,  
"path": "userId"  
},  
"properties": {  
"userId": {  
"type": "string",  
"index": "not\_analyzed"  
},  
"extra": {  
"type": "nested",  
"properties": {  
"key": {  
"type": "string",  
"index": "not\_analyzed"  
},  
"value": {  
"type": "string",  
"index": "analyzed"  
}  
}  
}  
}  
}  
}

The above ends up with the following result when calling for the mapping (curl -XGET localhost:9200/my\_index/action/\_mapping?pretty ):

{  
"action": {  
"\_all": {  
"enabled": false  
},  
"\_type": {  
"index": "no"  
},  
"\_timestamp": {  
"enabled": true,  
"store": "yes"  
},  
"\_routing": {  
"required": true,  
"path": "userId"  
},  
"properties": {  
"userId": {  
"type" : "string",  
"index" : "not\_analyzed",  
"omit\_norms" : true,  
"index\_options" : "docs"  
},  
"extra": {  
"type": "nested",  
"properties": {  
"key": {  
"type" : "string",  
"index" : "not\_analyzed",  
"omit\_norms" : true,  
"index\_options" : "docs" },  
"value": {  
"type": "string"  
}  
}  
}  
}  
}  
}

Should it display index type as analyzed? furthermore I cannot search based on this field? Should I search by defining the analyzer?

ES version 0.90.7 but i noticed this since version 0.90.2, probably I'm doing something wrong here.

Looking forward for your reply  
Thank you

--  
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/01ec164d-bb31-4e5b-87d2-1a9abadb0b69%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/01ec164d-bb31-4e5b-87d2-1a9abadb0b69%40googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

--  
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/etPan.52b06c0e.3dc240fb.6956%40MacBook-Air-de-David.local](https://groups.google.com/d/msgid/elasticsearch/etPan.52b06c0e.3dc240fb.6956%40MacBook-Air-de-David.local).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![Thomas\_Bolis](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/thomas_bolis/32/700_2.png) [@Thomas\_Bolis](https://discuss.elastic.co/u/Thomas_Bolis)\
**Post date:** [December 17, 2013, 3:37pm UTC](https://discuss.elastic.co/t/cannot-set-string-type-to-analyzed/14914/3 "2013-12-17T15:37:35Z")

</div>

Thanks for your reply

Here is an example:

{  
"query":{  
"filtered":{  
"query":{"term":{"userId":"testUser1"}},  
"filter":{  
"nested":{  
"path":"extra",  
"query":{  
"filtered":{  
"query":{"match\_all":{}},  
"filter":{  
"bool":{  
"must":[  
{"term":{"key" : "city"}},  
{"term":{"value" : "Stockholm"}}  
]  
}  
}  
}  
}  
}  
}  
}  
},  
"size":0  
}

I have inserted data with key city and value Stockholm in my scenario, the  
thing is that if I change the mapping to not\_analyzed and run the same  
scenario i get back data whereas if I set index to analyzed or not set it  
at all (default value) then I do not get back results which leads me to the  
conclusion that somehow analyzed is not accepted when setting mapping

Thomas

On Tuesday, December 17, 2013 5:10:58 PM UTC+2, Thomas wrote:

> Hi,
> 
> I'm trying to create a mapping for a nested document and I realize that i  
> cannot set the index type of a string field to analyzed:
> 
> {  
> "action": {  
> "\_all": {  
> "enabled": false  
> },  
> "\_type": {  
> "index": "no"  
> },  
> "\_timestamp": {  
> "enabled": true,  
> "store": "yes"  
> },  
> "\_routing": {  
> "required": true,  
> "path": "userId"  
> },  
> "properties": {  
> "userId": {  
> "type": "string",  
> "index": "not\_analyzed"  
> },  
> "extra": {  
> "type": "nested",  
> "properties": {  
> "key": {  
> "type": "string",  
> "index": "not\_analyzed"  
> },  
> _"value": {_
> 
> - "type": "string",\*
> - "index": "analyzed"\*
> - }\*  
> }  
> }  
> }  
> }  
> }
> 
> The above ends up with the following result when calling for the mapping  
> (curl -XGET localhost:9200/my\_index/action/\_mapping?pretty ):
> 
> {  
> "action": {  
> "\_all": {  
> "enabled": false  
> },  
> "\_type": {  
> "index": "no"  
> },  
> "\_timestamp": {  
> "enabled": true,  
> "store": "yes"  
> },  
> "\_routing": {  
> "required": true,  
> "path": "userId"  
> },  
> "properties": {  
> "userId": {  
> "type" : "string",  
> "index" : "not\_analyzed",  
> "omit\_norms" : true,  
> "index\_options" : "docs"  
> },  
> "extra": {  
> "type": "nested",  
> "properties": {  
> "key": {  
> "type" : "string",  
> "index" :  
> "not\_analyzed",  
> "omit\_norms" : true,  
> "index\_options" : "docs"  
> },  
> _"value": {_
> 
> - "type": "string"\*
> - }\*  
> }  
> }  
> }  
> }  
> }
> 
> Should it display index type as analyzed? furthermore I cannot search  
> based on this field? Should I search by defining the analyzer?
> 
> ES version 0.90.7 but i noticed this since version 0.90.2, probably I'm  
> doing something wrong here.
> 
> Looking forward for your reply  
> Thank you

--  
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/b31fd783-2477-4011-8f59-6c7651b0437e%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/b31fd783-2477-4011-8f59-6c7651b0437e%40googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [December 17, 2013, 3:43pm UTC](https://discuss.elastic.co/t/cannot-set-string-type-to-analyzed/14914/4 "2013-12-17T15:43:55Z")

</div>

I think it's the intended result.

When not\_analyzed, Stockholm is indexed as Stockholm  
When analyzed, Stockholm is indexed as stockholm

TermFilter is not analyzed. So searching for Stockholm will work with not\_analyzed and won't with analyzed.

If I'm wrong, could it be possible to GIST a full curl recreation as explained here, please: [http://www.elasticsearch.org/help/](http://www.elasticsearch.org/help/)  
It will help a lot to understand what you are doing.

--  
David Pilato | Technical Advocate | [Elasticsearch.com](http://Elasticsearch.com)  
@dadoonet | @elasticsearchfr

Le 17 décembre 2013 at 16:37:38, Thomas ([thomas.bolis@gmail.com](mailto:thomas.bolis@gmail.com)) a écrit:

Thanks for your reply

Here is an example:

{  
"query":{  
"filtered":{  
"query":{"term":{"userId":"testUser1"}},  
"filter":{  
"nested":{  
"path":"extra",  
"query":{  
"filtered":{  
"query":{"match\_all":{}},  
"filter":{  
"bool":{  
"must":[  
{"term":{"key" : "city"}},  
{"term":{"value" : "Stockholm"}}  
]  
}  
}  
}  
}  
}  
}  
}  
},  
"size":0  
}

I have inserted data with key city and value Stockholm in my scenario, the thing is that if I change the mapping to not\_analyzed and run the same scenario i get back data whereas if I set index to analyzed or not set it at all (default value) then I do not get back results which leads me to the conclusion that somehow analyzed is not accepted when setting mapping

Thomas

On Tuesday, December 17, 2013 5:10:58 PM UTC+2, Thomas wrote:  
Hi,

I'm trying to create a mapping for a nested document and I realize that i cannot set the index type of a string field to analyzed:

{  
"action": {  
"\_all": {  
"enabled": false  
},  
"\_type": {  
"index": "no"  
},  
"\_timestamp": {  
"enabled": true,  
"store": "yes"  
},  
"\_routing": {  
"required": true,  
"path": "userId"  
},  
"properties": {  
"userId": {  
"type": "string",  
"index": "not\_analyzed"  
},  
"extra": {  
"type": "nested",  
"properties": {  
"key": {  
"type": "string",  
"index": "not\_analyzed"  
},  
"value": {  
"type": "string",  
"index": "analyzed"  
}  
}  
}  
}  
}  
}

The above ends up with the following result when calling for the mapping (curl -XGET localhost:9200/my\_index/action/\_mapping?pretty ):

{  
"action": {  
"\_all": {  
"enabled": false  
},  
"\_type": {  
"index": "no"  
},  
"\_timestamp": {  
"enabled": true,  
"store": "yes"  
},  
"\_routing": {  
"required": true,  
"path": "userId"  
},  
"properties": {  
"userId": {  
"type" : "string",  
"index" : "not\_analyzed",  
"omit\_norms" : true,  
"index\_options" : "docs"  
},  
"extra": {  
"type": "nested",  
"properties": {  
"key": {  
"type" : "string",  
"index" : "not\_analyzed",  
"omit\_norms" : true,  
"index\_options" : "docs" },  
"value": {  
"type": "string"  
}  
}  
}  
}  
}  
}

Should it display index type as analyzed? furthermore I cannot search based on this field? Should I search by defining the analyzer?

ES version 0.90.7 but i noticed this since version 0.90.2, probably I'm doing something wrong here.

Looking forward for your reply  
Thank you

--  
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/b31fd783-2477-4011-8f59-6c7651b0437e%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/b31fd783-2477-4011-8f59-6c7651b0437e%40googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

--  
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/etPan.52b0713b.47398c89.6956%40MacBook-Air-de-David.local](https://groups.google.com/d/msgid/elasticsearch/etPan.52b0713b.47398c89.6956%40MacBook-Air-de-David.local).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![Thomas\_Bolis](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/thomas_bolis/32/700_2.png) [@Thomas\_Bolis](https://discuss.elastic.co/u/Thomas_Bolis)\
**Post date:** [December 17, 2013, 3:52pm UTC](https://discuss.elastic.co/t/cannot-set-string-type-to-analyzed/14914/5 "2013-12-17T15:52:09Z")

</div>

You are 100% correct I changed it to lowercase and got back the desired  
result

Thanks a lot David

Thomas

On Tuesday, December 17, 2013 5:10:58 PM UTC+2, Thomas wrote:

> Hi,
> 
> I'm trying to create a mapping for a nested document and I realize that i  
> cannot set the index type of a string field to analyzed:
> 
> {  
> "action": {  
> "\_all": {  
> "enabled": false  
> },  
> "\_type": {  
> "index": "no"  
> },  
> "\_timestamp": {  
> "enabled": true,  
> "store": "yes"  
> },  
> "\_routing": {  
> "required": true,  
> "path": "userId"  
> },  
> "properties": {  
> "userId": {  
> "type": "string",  
> "index": "not\_analyzed"  
> },  
> "extra": {  
> "type": "nested",  
> "properties": {  
> "key": {  
> "type": "string",  
> "index": "not\_analyzed"  
> },  
> _"value": {_
> 
> - "type": "string",\*
> - "index": "analyzed"\*
> - }\*  
> }  
> }  
> }  
> }  
> }
> 
> The above ends up with the following result when calling for the mapping  
> (curl -XGET localhost:9200/my\_index/action/\_mapping?pretty ):
> 
> {  
> "action": {  
> "\_all": {  
> "enabled": false  
> },  
> "\_type": {  
> "index": "no"  
> },  
> "\_timestamp": {  
> "enabled": true,  
> "store": "yes"  
> },  
> "\_routing": {  
> "required": true,  
> "path": "userId"  
> },  
> "properties": {  
> "userId": {  
> "type" : "string",  
> "index" : "not\_analyzed",  
> "omit\_norms" : true,  
> "index\_options" : "docs"  
> },  
> "extra": {  
> "type": "nested",  
> "properties": {  
> "key": {  
> "type" : "string",  
> "index" :  
> "not\_analyzed",  
> "omit\_norms" : true,  
> "index\_options" : "docs"  
> },  
> _"value": {_
> 
> - "type": "string"\*
> - }\*  
> }  
> }  
> }  
> }  
> }
> 
> Should it display index type as analyzed? furthermore I cannot search  
> based on this field? Should I search by defining the analyzer?
> 
> ES version 0.90.7 but i noticed this since version 0.90.2, probably I'm  
> doing something wrong here.
> 
> Looking forward for your reply  
> Thank you

--  
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/804070ec-5601-45b5-83e4-840d72f348af%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/804070ec-5601-45b5-83e4-840d72f348af%40googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<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, 2:00am UTC](https://discuss.elastic.co/t/cannot-set-string-type-to-analyzed/14914/6 "2017-07-06T02:00:38Z")

</div>


