Skip to content

Commit

Permalink
Return a conflict when trying to enable/disable norms.
Browse files Browse the repository at this point in the history
Close #4761
  • Loading branch information
jpountz committed Jan 20, 2014
1 parent f0bce08 commit 6469f6e
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
Expand Up @@ -561,6 +561,9 @@ public void merge(Mapper mergeWith, MergeContext mergeContext) throws MergeMappi
// 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");
}
Expand Down
Expand Up @@ -182,6 +182,16 @@ public void updateMappingWithConflicts() throws Exception {
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
*/
Expand Down

0 comments on commit 6469f6e

Please sign in to comment.