# Got shard failure when i delete mapping for types

**URL:** <https://discuss.elastic.co/t/got-shard-failure-when-i-delete-mapping-for-types/12183>\
**Category:** Elasticsearch\
**Created:** [May 30, 2013, 4:39am UTC](https://discuss.elastic.co/t/got-shard-failure-when-i-delete-mapping-for-types/12183 "2013-05-30T04:39:48Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Marcus\_Park](https://avatars.discourse-cdn.com/v4/letter/m/2acd7d/32.png) [@Marcus\_Park](https://discuss.elastic.co/u/Marcus_Park)\
**Post date:** [May 30, 2013, 4:39am UTC](https://discuss.elastic.co/t/got-shard-failure-when-i-delete-mapping-for-types/12183/1 "2013-05-30T04:39:48Z")

</div>

Hi all,  
I'm testing delete mapping for types, but in a certain time i get shard  
failure error. 1 shard goes to unassigned shard.

Scenario is like below:

- put mappings for 15 different types
- insert a couple of docs with 3 test fields for each types
- delete all the mappings
- repeat above test code again and again until i get the shard error

you may refer the code here. [https://gist.github.com/mintbass/5675355](https://gist.github.com/mintbass/5675355)

The error occured because 'no index mapper found for field' at  
org.elasticsearch.index.codec.PerFieldMappingPostingFormatCodec class.  
So, i modified a class to return the defaultPostingFormat value not to  
throw an exception in  
org.elasticsearch.index.codec.PerFieldMappingPostingFormatCodec.

```
@Override
public PostingsFormat getPostingsFormatForField(String field) {
    final FieldMappers indexName = mapperService.indexName(field);
    if (indexName == null) {
        //throw new ElasticSearchIllegalStateException("no index mapper 

```

found for field: [" + field + "]");  
return defaultPostingFormat;  
}  
PostingsFormatProvider postingsFormat =  
indexName.mapper().postingsFormatProvider();  
return postingsFormat != null ? postingsFormat.get() :  
defaultPostingFormat;  
}

Is there any workaround to avoid this?  
Could it be any problem the code i changed in the future? so far, i don't  
see any problem.

Thanks

--  
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).  
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:** [May 30, 2013, 5:34am UTC](https://discuss.elastic.co/t/got-shard-failure-when-i-delete-mapping-for-types/12183/2 "2013-05-30T05:34:56Z")

</div>

May be you should wait for a Yellow cluster status after each cluster change call (remove index, create index, delete mapping...).

Could it help?

--  
David 😉  
Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs

Le 30 mai 2013 à 06:39, Marcus Park [mintbass@gmail.com](mailto:mintbass@gmail.com) a écrit :

Hi all,  
I'm testing delete mapping for types, but in a certain time i get shard failure error. 1 shard goes to unassigned shard.

Scenario is like below:

- put mappings for 15 different types
- insert a couple of docs with 3 test fields for each types
- delete all the mappings
- repeat above test code again and again until i get the shard error

you may refer the code here. [https://gist.github.com/mintbass/5675355](https://gist.github.com/mintbass/5675355)

The error occured because 'no index mapper found for field' at org.elasticsearch.index.codec.PerFieldMappingPostingFormatCodec class.  
So, i modified a class to return the defaultPostingFormat value not to throw an exception in org.elasticsearch.index.codec.PerFieldMappingPostingFormatCodec.

```
@Override
public PostingsFormat getPostingsFormatForField(String field) {
    final FieldMappers indexName = mapperService.indexName(field);
    if (indexName == null) {
        //throw new ElasticSearchIllegalStateException("no index mapper found for field: [" + field + "]");
        return defaultPostingFormat;
    }
    PostingsFormatProvider postingsFormat = indexName.mapper().postingsFormatProvider();
    return postingsFormat != null ? postingsFormat.get() : defaultPostingFormat;
}

```

Is there any workaround to avoid this?  
Could it be any problem the code i changed in the future? so far, i don't see any problem.

Thanks

--  
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).  
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).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![simonw\_2](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/simonw_2/32/1130_2.png) [@simonw\_2](https://discuss.elastic.co/u/simonw_2)\
**Post date:** [May 30, 2013, 8:07am UTC](https://discuss.elastic.co/t/got-shard-failure-when-i-delete-mapping-for-types/12183/3 "2013-05-30T08:07:01Z")

</div>

hey,

On Thursday, May 30, 2013 6:39:48 AM UTC+2, Marcus Park wrote:

> Hi all,  
> I'm testing delete mapping for types, but in a certain time i get shard  
> failure error. 1 shard goes to unassigned shard.
> 
> Scenario is like below:
> 
> - put mappings for 15 different types
> - insert a couple of docs with 3 test fields for each types
> - delete all the mappings
> - repeat above test code again and again until i get the shard error
> 
> you may refer the code here. [https://gist.github.com/mintbass/5675355](https://gist.github.com/mintbass/5675355)

cool stuff that will help me to reproduce this.

> The error occured because 'no index mapper found for field' at  
> org.elasticsearch.index.codec.PerFieldMappingPostingFormatCodec class.  
> So, i modified a class to return the defaultPostingFormat value not to  
> throw an exception in  
> org.elasticsearch.index.codec.PerFieldMappingPostingFormatCodec.
> 
> ```
> @Override
> public PostingsFormat getPostingsFormatForField(String field) {
> final FieldMappers indexName = mapperService.indexName(field);
> if (indexName == null) {
> //throw new ElasticSearchIllegalStateException("no index 
> 
> ```
> 
> mapper found for field: [" + field + "]");  
> return defaultPostingFormat;  
> }  
> PostingsFormatProvider postingsFormat =  
> indexName.mapper().postingsFormatProvider();  
> return postingsFormat != null ? postingsFormat.get() :  
> defaultPostingFormat;  
> }

I added the same thing like 6 days ago here:

> <https://github.com/elastic/elasticsearch/commit/6e366bae34c0128e6f710f79422eab1412616cb4>
>
> If we throw an exception in the PostingsFormat during a merge we essentially
> fai…l the entire merge which can lead to a corrupt index. We should rather
> return the default postings format for the new segment and log a warning.
> 
> Closes #3088

you should be fine with your change - that is a bug though. the soon coming  
0.90.1 release will fix the issue.

simon

> Is there any workaround to avoid this?  
> Could it be any problem the code i changed in the future? so far, i don't  
> see any problem.
> 
> Thanks

--  
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).  
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:33am UTC](https://discuss.elastic.co/t/got-shard-failure-when-i-delete-mapping-for-types/12183/4 "2017-07-06T02:33:56Z")

</div>


