# Analyze on text field

**URL:** <https://discuss.elastic.co/t/analyze-on-text-field/131452>\
**Category:** Elasticsearch\
**Created:** [May 11, 2018, 9:49am UTC](https://discuss.elastic.co/t/analyze-on-text-field/131452 "2018-05-11T09:49:33Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Prashant\_Mishra](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/prashant_mishra/32/53912_2.png) [@Prashant\_Mishra](https://discuss.elastic.co/u/Prashant_Mishra)\
**Post date:** [May 11, 2018, 9:49am UTC](https://discuss.elastic.co/t/analyze-on-text-field/131452/1 "2018-05-11T09:49:33Z")

</div>

[https://www.elastic.co/guide/en/elasticsearch/client/javascript-api/current/api-reference.html#api-msearch](https://www.elastic.co/guide/en/elasticsearch/client/javascript-api/current/api-reference.html#api-msearch)

I creating index using Bulk api from the above API references. where my type has a field with text which contains "." and alphanumeric. so want to make this field not\_analyzed.

myidext/\_anayzed

{  
"field": "subfamilycode",  
"text": "ENS.08.004.S20"  
}

returns  
{  
"tokens": [  
{  
"token": "ens",  
"start\_offset": 0,  
"end\_offset": 3,  
"type": "",  
"position": 0  
},  
{  
"token": "08.004",  
"start\_offset": 4,  
"end\_offset": 10,  
"type": "",  
"position": 1  
},  
{  
"token": "s20",  
"start\_offset": 11,  
"end\_offset": 14,  
"type": "",  
"position": 2  
}  
]  
}

i want it as  
{  
"tokens": [  
{  
"token": "ENS.08.004.S20",  
"start\_offset": 0,  
"end\_offset": 3,  
"type": "",  
"position": 0  
}  
}

---

<div class="post-metadata">

**Author:** ![tdasch](https://avatars.discourse-cdn.com/v4/letter/t/58f4c7/32.png) [@tdasch](https://discuss.elastic.co/u/tdasch)\
**Post date:** [May 11, 2018, 10:56am UTC](https://discuss.elastic.co/t/analyze-on-text-field/131452/2 "2018-05-11T10:56:25Z")

</div>

Someone please correct me if I am wrong. I believe you need to use a "keyword" analyzer which uses the "keyword" tokenizer. The doc [https://www.elastic.co/guide/en/elasticsearch/reference/current/analysis-keyword-analyzer.html](https://www.elastic.co/guide/en/elasticsearch/reference/current/analysis-keyword-analyzer.html).

---

<div class="post-metadata">

**Author:** ![Ivan](https://avatars.discourse-cdn.com/v4/letter/i/df788c/32.png) [@Ivan](https://discuss.elastic.co/u/Ivan)\
**Post date:** [May 11, 2018, 6:22pm UTC](https://discuss.elastic.co/t/analyze-on-text-field/131452/3 "2018-05-11T18:22:14Z")

</div>

It is even easier if you simply set the type of the field to be "keyword". No special analysis needed. [https://www.elastic.co/guide/en/elasticsearch/reference/master/keyword.html](https://www.elastic.co/guide/en/elasticsearch/reference/master/keyword.html)

---

<div class="post-metadata">

**Author:** ![Prashant\_Mishra](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/prashant_mishra/32/53912_2.png) [@Prashant\_Mishra](https://discuss.elastic.co/u/Prashant_Mishra)\
**Post date:** [May 14, 2018, 9:49am UTC](https://discuss.elastic.co/t/analyze-on-text-field/131452/4 "2018-05-14T09:49:40Z")

</div>

@Ivan and @tdasch thank you, But the Javascript api is not allowing to put the mapping before index creation..

Please see the listed API url Above. There is function "client.indices.putMapping(....)".  
If i am wrong then please correct me.

---

<div class="post-metadata">

**Author:** ![tdasch](https://avatars.discourse-cdn.com/v4/letter/t/58f4c7/32.png) [@tdasch](https://discuss.elastic.co/u/tdasch)\
**Post date:** [May 14, 2018, 2:50pm UTC](https://discuss.elastic.co/t/analyze-on-text-field/131452/5 "2018-05-14T14:50:27Z")

</div>

Can you post the error you are getting please?

---

<div class="post-metadata">

**Author:** ![Prashant\_Mishra](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/prashant_mishra/32/53912_2.png) [@Prashant\_Mishra](https://discuss.elastic.co/u/Prashant_Mishra)\
**Post date:** [May 15, 2018, 6:47am UTC](https://discuss.elastic.co/t/analyze-on-text-field/131452/6 "2018-05-15T06:47:34Z")

</div>

@tdasch below error is coming if index is not created and i am trying to put the mapping.

Error: [index\_not\_found\_exception] no such index, with { resource.type="index\_or\_alias" & resource.id="my\_index\_name" & index\_uuid="_na_" & index="my\_index\_name" } :: {"path":"/my\_index\_name/\_mapping/my\_type","query":{},"body":"{"properties":{"code":{"type":"keyword","index":"not\_analyzed"},"fcode":{"fielddata":true,"fields":{"raw":{"index":"not\_analyzed","type":"string"}},"type":"string"},"title":{"fielddata":true,"fields":{"raw":{"index":"not\_analyzed","type":"string"}},"type":"string"},"sfcode":{"fielddata":true,"fields":{"raw":{"index":"not\_analyzed","type":"string"}},"type":"string"},"cLCode":{"fielddata":true,"fields":{"raw":{"index":"not\_analyzed","type":"string"}},"type":"string"}}}","stCode":404,"response":"{"error":{"root\_cause":[{"type":"index\_not\_found\_exception","reason":"no such index","resource.type":"index\_or\_alias","resource.id":"my\_index\_name","index\_uuid":"_na_","index":"my\_index\_name"}],"type":"index\_not\_found\_exception","reason":"no such index","resource.type":"index\_or\_alias","resource.id":"my\_index\_name","index\_uuid":"_na_","index":"my\_index\_name"},"status":404}"}

Even if i insert all records using the "BULK API" then "Code" field is set as text type and later it not allowing to change into type "keyword" by put mapping.

---

<div class="post-metadata">

**Author:** ![tdasch](https://avatars.discourse-cdn.com/v4/letter/t/58f4c7/32.png) [@tdasch](https://discuss.elastic.co/u/tdasch)\
**Post date:** [May 16, 2018, 12:25am UTC](https://discuss.elastic.co/t/analyze-on-text-field/131452/7 "2018-05-16T00:25:08Z")

</div>

Prashant,

I wonder if this link might help with the mapping problem? [https://stackoverflow.com/questions/22325708/elasticsearch-create-index-with-mappings-using-javascript](https://stackoverflow.com/questions/22325708/elasticsearch-create-index-with-mappings-using-javascript)

---

<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:** [June 13, 2018, 12:25am UTC](https://discuss.elastic.co/t/analyze-on-text-field/131452/8 "2018-06-13T00:25:10Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
