Skip to content

Commit

Permalink
Mapping: Fixes Merging of default analyzer
Browse files Browse the repository at this point in the history
Fixed behaviour where two representations of the default index analyzer weren't being treated as equivalent. Added REST test to confirm fix.

Closes #2716
  • Loading branch information
nwarz authored and colings86 committed Nov 14, 2014
1 parent 17c8a1c commit 6e98bd7
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 3 deletions.
34 changes: 34 additions & 0 deletions rest-api-spec/test/indices.put_mapping/all_path_options.yaml
Expand Up @@ -176,3 +176,37 @@ setup:
catch: param
indices.put_mapping: {}

---
"post a mapping with default analyzer twice":

- do:
indices.put_mapping:
index: test_index1
type: test_type
body:
test_type:
dynamic: false
properties:
text:
index: analyzed
analyzer: default
type: string

- do:
indices.put_mapping:
index: test_index1
type: test_type
body:
test_type:
dynamic: false
properties:
text:
index: analyzed
analyzer: default
type: string

- do:
indices.get_mapping: {}

- match: {test_index1.mappings.test_type.properties.text.type: string}

Expand Up @@ -595,15 +595,18 @@ public void merge(Mapper mergeWith, MergeContext mergeContext) throws MergeMappi
if (this.fieldType().storeTermVectorPayloads() != fieldMergeWith.fieldType().storeTermVectorPayloads()) {
mergeContext.addConflict("mapper [" + names.fullName() + "] has different store_term_vector_payloads values");
}
if (this.indexAnalyzer == null) {
if (fieldMergeWith.indexAnalyzer != null) {

// null and "default"-named index analyzers both mean the default is used
if (this.indexAnalyzer == null || "default".equals(this.indexAnalyzer.name())) {
if (fieldMergeWith.indexAnalyzer != null && !"default".equals(fieldMergeWith.indexAnalyzer.name())) {
mergeContext.addConflict("mapper [" + names.fullName() + "] has different index_analyzer");
}
} else if (fieldMergeWith.indexAnalyzer == null) {
} else if (fieldMergeWith.indexAnalyzer == null || "default".equals(fieldMergeWith.indexAnalyzer.name())) {
mergeContext.addConflict("mapper [" + names.fullName() + "] has different index_analyzer");
} else if (!this.indexAnalyzer.name().equals(fieldMergeWith.indexAnalyzer.name())) {
mergeContext.addConflict("mapper [" + names.fullName() + "] has different index_analyzer");
}

if (!this.names().equals(fieldMergeWith.names())) {
mergeContext.addConflict("mapper [" + names.fullName() + "] has different index_name");
}
Expand Down

0 comments on commit 6e98bd7

Please sign in to comment.