# Apply analyzer to multiple documents properties (or on index) at once

**URL:** <https://discuss.elastic.co/t/apply-analyzer-to-multiple-documents-properties-or-on-index-at-once/124482>\
**Category:** Elasticsearch\
**Created:** [March 19, 2018, 5:20am UTC](https://discuss.elastic.co/t/apply-analyzer-to-multiple-documents-properties-or-on-index-at-once/124482 "2018-03-19T05:20:09Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![nmathur](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nmathur/32/21451_2.png) [@nmathur](https://discuss.elastic.co/u/nmathur)\
**Post date:** [March 19, 2018, 5:20am UTC](https://discuss.elastic.co/t/apply-analyzer-to-multiple-documents-properties-or-on-index-at-once/124482/1 "2018-03-19T05:20:09Z")

</div>

I am working on elasticsearch Nest.

I am trying to set `analyzer` to property of a document but process is always unsuccessful because `another document has property with same name` .. I am getting below error message:

**{Type: illegal\_argument\_exception Reason: "Mapper for [departmentName] conflicts with existing mapping in other types:  
[mapper [departmentName] has different [analyzer]]"}**

Here is the code I am using to put mapping:

```auto
 ESClientContext.Map<Department>(m => m.Index("company").Type("department")
                 .Properties(p => p
                            .Text(t => t
                                  .Name(n => n.DepartmentName)
                                        .Analyzer("keyword")
                                        .Fielddata(true)
                                     )).UpdateAllTypes(true)); 

```

Employee also have DepartmentName ..

Please help and guide. Updated as suggested.

---

<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:** [March 19, 2018, 9:25am UTC](https://discuss.elastic.co/t/apply-analyzer-to-multiple-documents-properties-or-on-index-at-once/124482/2 "2018-03-19T09:25:57Z")

</div>

Please format your code, logs or configuration files using `</>` icon as explained in [this guide](https://discuss.elastic.co/t/about-the-elasticsearch-category/21) and **not the citation button**. It will make your post more readable.

Or use markdown style like:

````
```
CODE
```

````

There's a live preview panel for exactly this reasons.

Please update your post.

I can't really answer but please be aware that in 6.x you can't have anymore multiple mappings in the same index  
So it's better to start thinking of your project a bit differently and have multiple indices for example.

Which will solve your problem. 😉

---

<div class="post-metadata">

**Author:** ![nmathur](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nmathur/32/21451_2.png) [@nmathur](https://discuss.elastic.co/u/nmathur)\
**Post date:** [March 19, 2018, 10:32am UTC](https://discuss.elastic.co/t/apply-analyzer-to-multiple-documents-properties-or-on-index-at-once/124482/3 "2018-03-19T10:32:24Z")

</div>

I tried "\</\>" but preview window was not reflecting any change .. so I had to do that .. I am using Opera 51.0 browser.

multiple indices .. is gonna cost us a huge change .. I have approve 25 docs in my index .. I am using 5.5 right now .... so your suggestion is that we should create single index for single doc .. my main issue is analyzer .. I need to index the string as it is .. can you please share any solution for that which can work for me without breaking all docs to many indices? ..

One more point I want to mention .. my index is already created and I want to update the mapping of Department and Employee both .. departmentName analyzer change .. now is there any way to apply mapping change to both at once (that was actually my question, sorry the UI was not so clear to you) .. when I try to do put mapping one by one I am getting exception at first try ...

Hope my case is clear .. please help.

---

<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:** [March 19, 2018, 3:56pm UTC](https://discuss.elastic.co/t/apply-analyzer-to-multiple-documents-properties-or-on-index-at-once/124482/5 "2018-03-19T15:56:33Z")

</div>

> multiple indices .. is gonna cost us a huge change .. I have approve 25 docs in my index .. I am using 5.5 right now .... so your suggestion is that we should create single index for single doc ..

Yes. Be prepared for 6.x ASAP.

> my main issue is analyzer .. I need to index the string as it is .. can you please share any solution for that which can work for me without breaking all docs to many indices? ..

Use a `keyword` analyzer or a `keyword` data type in your mapping.

> my index is already created and I want to update the mapping of Department and Employee both .. departmentName analyzer change ..

You need to reindex for that. You can not change the settings of an existing field.

---

<div class="post-metadata">

**Author:** ![nmathur](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nmathur/32/21451_2.png) [@nmathur](https://discuss.elastic.co/u/nmathur)\
**Post date:** [March 20, 2018, 4:30am UTC](https://discuss.elastic.co/t/apply-analyzer-to-multiple-documents-properties-or-on-index-at-once/124482/6 "2018-03-20T04:30:23Z")

</div>

Hello dadoonet,

Thanks a lot for your help and time ... recreating index worked for me. 🙂 .. hope this will work in 6.x without any issue.

---

<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:** [March 20, 2018, 8:04am UTC](https://discuss.elastic.co/t/apply-analyzer-to-multiple-documents-properties-or-on-index-at-once/124482/7 "2018-03-20T08:04:29Z")

</div>

Do you still have 2 types in your index?

---

<div class="post-metadata">

**Author:** ![nmathur](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nmathur/32/21451_2.png) [@nmathur](https://discuss.elastic.co/u/nmathur)\
**Post date:** [March 20, 2018, 10:16am UTC](https://discuss.elastic.co/t/apply-analyzer-to-multiple-documents-properties-or-on-index-at-once/124482/8 "2018-03-20T10:16:36Z")

</div>

yes .. I have many types/documents in single index.

---

<div class="post-metadata">

**Author:** ![nmathur](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nmathur/32/21451_2.png) [@nmathur](https://discuss.elastic.co/u/nmathur)\
**Post date:** [March 20, 2018, 10:24am UTC](https://discuss.elastic.co/t/apply-analyzer-to-multiple-documents-properties-or-on-index-at-once/124482/9 "2018-03-20T10:24:56Z")

</div>

> [@dadoonet](#):
>
> 6.x you can't have anymore multiple mappings in the same index

that means .. one index - one document .. right?

---

<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:** [March 20, 2018, 10:29am UTC](https://discuss.elastic.co/t/apply-analyzer-to-multiple-documents-properties-or-on-index-at-once/124482/10 "2018-03-20T10:29:09Z")

</div>

One index, one type of document.

> yes .. I have many types/documents in single index.

So you will be able to upgrade your existing indices to 6.x but you won't be able to upgrade to 7.x.  
And you won't be able to create the same data structure from scratch in 6.x.

---

<div class="post-metadata">

**Author:** ![nmathur](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nmathur/32/21451_2.png) [@nmathur](https://discuss.elastic.co/u/nmathur)\
**Post date:** [March 20, 2018, 10:40am UTC](https://discuss.elastic.co/t/apply-analyzer-to-multiple-documents-properties-or-on-index-at-once/124482/11 "2018-03-20T10:40:28Z")

</div>

ok .. so I can't have `Employee` and `Department` in same index in 6.x .. but I can upgrade my old index .. but if in future I will have any requirement to reindex .. then I will have to face a huge change .. right? ...

And if now I apply changes keeping 6.x in mind . will that help me with 7.x too?

---

<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:** [March 20, 2018, 1:17pm UTC](https://discuss.elastic.co/t/apply-analyzer-to-multiple-documents-properties-or-on-index-at-once/124482/12 "2018-03-20T13:17:38Z")

</div>

> [@nmathur](#):
>
> And if now I apply changes keeping 6.x in mind . will that help me with 7.x too?

Definitely yes.

---

<div class="post-metadata">

**Author:** ![nmathur](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nmathur/32/21451_2.png) [@nmathur](https://discuss.elastic.co/u/nmathur)\
**Post date:** [April 14, 2018, 11:06am UTC](https://discuss.elastic.co/t/apply-analyzer-to-multiple-documents-properties-or-on-index-at-once/124482/13 "2018-04-14T11:06:54Z")

</div>

Hello dadoonet,

I followed your suggestion and changes my mapping to once index one type of document .. actually in my case now I have one document in one index .. now I needed to change analyzer for one on my document's text field but getting this error -

> Mapper for [name] conflicts with existing mapping in other types: [mapper [name] has different [analyzer]]

Existing mapping is like this:

> "name": {  
> "type": "text",  
> "fielddata": true  
> }

I want to change it to following:

> "name": {  
> "type": "text",  
> "analyzer": "keyword",  
> "fielddata": true  
> },

The index have only one document in it .. but still getting "other types" related issue. Please guide .. how to solve this without removing the index.

Thanks in advance.

---

<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:** [April 14, 2018, 12:26pm UTC](https://discuss.elastic.co/t/apply-analyzer-to-multiple-documents-properties-or-on-index-at-once/124482/14 "2018-04-14T12:26:08Z")

</div>

You need to reindex (create a new index and index data again).

---

<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:** [May 12, 2018, 12:26pm UTC](https://discuss.elastic.co/t/apply-analyzer-to-multiple-documents-properties-or-on-index-at-once/124482/15 "2018-05-12T12:26:23Z")

</div>

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