# How to apply English analyzer to a set of documents already indexed

**URL:** <https://discuss.elastic.co/t/how-to-apply-english-analyzer-to-a-set-of-documents-already-indexed/87253>\
**Category:** Elasticsearch\
**Created:** [May 26, 2017, 12:11pm UTC](https://discuss.elastic.co/t/how-to-apply-english-analyzer-to-a-set-of-documents-already-indexed/87253 "2017-05-26T12:11:06Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Riccardo\_Spampinato](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/riccardo_spampinato/32/18534_2.png) [@Riccardo\_Spampinato](https://discuss.elastic.co/u/Riccardo_Spampinato)\
**Post date:** [May 26, 2017, 12:11pm UTC](https://discuss.elastic.co/t/how-to-apply-english-analyzer-to-a-set-of-documents-already-indexed/87253/1 "2017-05-26T12:11:06Z")

</div>

Hi everyone,  
I'm a newbie in Elasticsearch world and I'm trying to do something with email. In particular I took the Enron email dataset and I indexed it into elastic database (I took just one folder of the whole dataset to make the computation easier) . This is the mapping I put:

[https://pastebin.com/RyZ3ez3V](https://pastebin.com/RyZ3ez3V)

Now I'd like to do some processing actions (tokenizing, stemming and removing stopwords) on the content of the body of each email. I had a look on language analyzers, but I do not know how to apply one of them to my case. I was wondering whether it's possible to use python and elasticsearch-dsl to create a script which takes the body of each email and does these kind of actions. Thank you guys

---

<div class="post-metadata">

**Author:** ![polyfractal](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/polyfractal/32/48162_2.png) [@polyfractal](https://discuss.elastic.co/u/polyfractal)\
**Post date:** [May 26, 2017, 2:53pm UTC](https://discuss.elastic.co/t/how-to-apply-english-analyzer-to-a-set-of-documents-already-indexed/87253/2 "2017-05-26T14:53:55Z")

</div>

Tokenizing/stemming/stopwords/etc is called "analysis" in Elasticsearch, and it's a process that's executed when the document is indexed. E.g. when you index a document, Elasticsearch will take the values from the document and run them through the configured analysis pipeline. The result of that analysis is then stored in ES for querying.

So you'll need to configure an Analyzer for the data you are indexing. You can read more about how analysis and mapping works here:

- [https://www.elastic.co/guide/en/elasticsearch/guide/current/mapping-analysis.html](https://www.elastic.co/guide/en/elasticsearch/guide/current/mapping-analysis.html)
- [https://www.elastic.co/guide/en/elasticsearch/guide/current/analysis-intro.html](https://www.elastic.co/guide/en/elasticsearch/guide/current/analysis-intro.html)
- [https://www.elastic.co/guide/en/elasticsearch/reference/current/analysis.html](https://www.elastic.co/guide/en/elasticsearch/reference/current/analysis.html)

Because this is an index-time operation, you'll need to re-index those documents to get them properly stemmed/stopworded, etc. RIght now they were analyzed with the default analyzer (`standard`) which does only basic processing (lowercasing, splitting on spaces/special characters, etc).

---

<div class="post-metadata">

**Author:** ![Riccardo\_Spampinato](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/riccardo_spampinato/32/18534_2.png) [@Riccardo\_Spampinato](https://discuss.elastic.co/u/Riccardo_Spampinato)\
**Post date:** [May 27, 2017, 9:49am UTC](https://discuss.elastic.co/t/how-to-apply-english-analyzer-to-a-set-of-documents-already-indexed/87253/3 "2017-05-27T09:49:52Z")

</div>

@polyfractal  
Thank you for your help. You completely understood my problem. I tried to follow your guides, but it seems that it doesn't apply any analyzer different from the standard one. I paste here the function I'm using to put the mapping:

[https://pastebin.com/ReLXcKft](https://pastebin.com/ReLXcKft)

In `message_body` field I added the `"analyzer": "english"` and I run again the script which deletes any existing index with the same name and indexes again the set of documents.

Where am I wrong?

---

<div class="post-metadata">

**Author:** ![Riccardo\_Spampinato](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/riccardo_spampinato/32/18534_2.png) [@Riccardo\_Spampinato](https://discuss.elastic.co/u/Riccardo_Spampinato)\
**Post date:** [May 29, 2017, 3:44pm UTC](https://discuss.elastic.co/t/how-to-apply-english-analyzer-to-a-set-of-documents-already-indexed/87253/4 "2017-05-29T15:44:54Z")

</div>

Anyone can help me? @polyfractal

---

<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 26, 2017, 3:44pm UTC](https://discuss.elastic.co/t/how-to-apply-english-analyzer-to-a-set-of-documents-already-indexed/87253/5 "2017-06-26T15:44:57Z")

</div>

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