Return a conflict when trying to enable/disable norms.

Close #4761
This commit is contained in:
Adrien Grand 2014-01-20 13:40:18 +01:00
parent f0bce08c30
commit 6469f6ef06
2 changed files with 13 additions and 0 deletions

View File

@ -561,6 +561,9 @@ public abstract class AbstractFieldMapper<T> implements FieldMapper<T> {
// when the doc_values field data format is configured
mergeContext.addConflict("mapper [" + names.fullName() + "] has different " + TypeParsers.DOC_VALUES + " values");
}
if (this.fieldType().omitNorms() != fieldMergeWith.fieldType.omitNorms()) {
mergeContext.addConflict("mapper [" + names.fullName() + "] has different `norms.enabled` values");
}
if (this.fieldType().tokenized() != fieldMergeWith.fieldType().tokenized()) {
mergeContext.addConflict("mapper [" + names.fullName() + "] has different tokenize values");
}

View File

@ -182,6 +182,16 @@ public class UpdateMappingTests extends ElasticsearchIntegrationTest {
assertThat(putMappingResponse.isAcknowledged(), equalTo(true));
}
@Test(expected = MergeMappingException.class)
public void updateMappingWithNormsConflicts() throws Exception {
client().admin().indices().prepareCreate("test")
.addMapping("type", "{\"type\":{\"properties\":{\"body\":{\"type\":\"string\", \"norms\": { \"enabled\": false }}}}}")
.execute().actionGet();
PutMappingResponse putMappingResponse = client().admin().indices().preparePutMapping("test").setType("type")
.setSource("{\"type\":{\"properties\":{\"body\":{\"type\":\"string\", \"norms\": { \"enabled\": true }}}}}")
.execute().actionGet();
}
/*
First regression test for https://github.com/elasticsearch/elasticsearch/issues/3381
*/