Address PR comments and fix customFieldDataSettings to still be copied
on merge
This commit is contained in:
parent
434b1c94b3
commit
a71b128738
|
@ -232,6 +232,7 @@ public class MappedFieldType extends FieldType {
|
||||||
public void validateCompatible(MappedFieldType other, List<String> conflicts) {
|
public void validateCompatible(MappedFieldType other, List<String> conflicts) {
|
||||||
boolean indexed = indexOptions() != IndexOptions.NONE;
|
boolean indexed = indexOptions() != IndexOptions.NONE;
|
||||||
boolean mergeWithIndexed = other.indexOptions() != IndexOptions.NONE;
|
boolean mergeWithIndexed = other.indexOptions() != IndexOptions.NONE;
|
||||||
|
// TODO: should be validating if index options go "up" (but "down" is ok)
|
||||||
if (indexed != mergeWithIndexed || tokenized() != other.tokenized()) {
|
if (indexed != mergeWithIndexed || tokenized() != other.tokenized()) {
|
||||||
conflicts.add("mapper [" + names().fullName() + "] has different index values");
|
conflicts.add("mapper [" + names().fullName() + "] has different index values");
|
||||||
}
|
}
|
||||||
|
@ -277,13 +278,7 @@ public class MappedFieldType extends FieldType {
|
||||||
conflicts.add("mapper [" + names().fullName() + "] has different index_name");
|
conflicts.add("mapper [" + names().fullName() + "] has different index_name");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (similarity() == null) {
|
if (Objects.equals(similarity(), other.similarity()) == false) {
|
||||||
if (other.similarity() != null) {
|
|
||||||
conflicts.add("mapper [" + names().fullName() + "] has different similarity");
|
|
||||||
}
|
|
||||||
} else if (other.similarity() == null) {
|
|
||||||
conflicts.add("mapper [" + names().fullName() + "] has different similarity");
|
|
||||||
} else if (!similarity().equals(other.similarity())) {
|
|
||||||
conflicts.add("mapper [" + names().fullName() + "] has different similarity");
|
conflicts.add("mapper [" + names().fullName() + "] has different similarity");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -45,7 +45,6 @@ import org.elasticsearch.index.mapper.MergeMappingException;
|
||||||
import org.elasticsearch.index.mapper.MergeResult;
|
import org.elasticsearch.index.mapper.MergeResult;
|
||||||
import org.elasticsearch.index.mapper.ParseContext;
|
import org.elasticsearch.index.mapper.ParseContext;
|
||||||
import org.elasticsearch.index.mapper.internal.AllFieldMapper;
|
import org.elasticsearch.index.mapper.internal.AllFieldMapper;
|
||||||
import org.elasticsearch.index.mapper.internal.TimestampFieldMapper;
|
|
||||||
import org.elasticsearch.index.similarity.SimilarityLookupService;
|
import org.elasticsearch.index.similarity.SimilarityLookupService;
|
||||||
import org.elasticsearch.index.similarity.SimilarityProvider;
|
import org.elasticsearch.index.similarity.SimilarityProvider;
|
||||||
|
|
||||||
|
@ -404,6 +403,11 @@ public abstract class AbstractFieldMapper implements FieldMapper {
|
||||||
// apply changeable values
|
// apply changeable values
|
||||||
this.fieldType = fieldMergeWith.fieldType().clone();
|
this.fieldType = fieldMergeWith.fieldType().clone();
|
||||||
this.fieldType().freeze();
|
this.fieldType().freeze();
|
||||||
|
if (fieldMergeWith.customFieldDataSettings != null) {
|
||||||
|
if (!Objects.equal(fieldMergeWith.customFieldDataSettings, this.customFieldDataSettings)) {
|
||||||
|
this.customFieldDataSettings = fieldMergeWith.customFieldDataSettings;
|
||||||
|
}
|
||||||
|
}
|
||||||
this.copyTo = fieldMergeWith.copyTo;
|
this.copyTo = fieldMergeWith.copyTo;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,6 +19,7 @@
|
||||||
|
|
||||||
package org.elasticsearch.index.mapper.update;
|
package org.elasticsearch.index.mapper.update;
|
||||||
|
|
||||||
|
import com.carrotsearch.randomizedtesting.annotations.Seed;
|
||||||
import org.apache.lucene.util.LuceneTestCase;
|
import org.apache.lucene.util.LuceneTestCase;
|
||||||
import org.elasticsearch.action.admin.indices.mapping.get.GetMappingsResponse;
|
import org.elasticsearch.action.admin.indices.mapping.get.GetMappingsResponse;
|
||||||
import org.elasticsearch.action.admin.indices.mapping.put.PutMappingResponse;
|
import org.elasticsearch.action.admin.indices.mapping.put.PutMappingResponse;
|
||||||
|
@ -182,9 +183,11 @@ public class UpdateMappingOnClusterTests extends ElasticsearchIntegrationTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testUpdateTimestamp() throws IOException {
|
@Seed(value = "12345678")
|
||||||
|
public void testUpdateTimestamp() throws Exception {
|
||||||
|
boolean enabled = randomBoolean();
|
||||||
XContentBuilder mapping = XContentFactory.jsonBuilder().startObject().startObject("type")
|
XContentBuilder mapping = XContentFactory.jsonBuilder().startObject().startObject("type")
|
||||||
.startObject("_timestamp").field("enabled", randomBoolean()).startObject("fielddata").field("loading", "lazy").field("format", "doc_values").endObject().field("store", "no").endObject()
|
.startObject("_timestamp").field("enabled", enabled).startObject("fielddata").field("loading", "lazy").field("format", "doc_values").endObject().field("store", "no").endObject()
|
||||||
.endObject().endObject();
|
.endObject().endObject();
|
||||||
client().admin().indices().prepareCreate("test").addMapping("type", mapping).get();
|
client().admin().indices().prepareCreate("test").addMapping("type", mapping).get();
|
||||||
GetMappingsResponse appliedMappings = client().admin().indices().prepareGetMappings("test").get();
|
GetMappingsResponse appliedMappings = client().admin().indices().prepareGetMappings("test").get();
|
||||||
|
@ -193,7 +196,7 @@ public class UpdateMappingOnClusterTests extends ElasticsearchIntegrationTest {
|
||||||
assertThat((String)((LinkedHashMap) timestampMapping.get("fielddata")).get("loading"), equalTo("lazy"));
|
assertThat((String)((LinkedHashMap) timestampMapping.get("fielddata")).get("loading"), equalTo("lazy"));
|
||||||
assertThat((String)((LinkedHashMap) timestampMapping.get("fielddata")).get("format"), equalTo("doc_values"));
|
assertThat((String)((LinkedHashMap) timestampMapping.get("fielddata")).get("format"), equalTo("doc_values"));
|
||||||
mapping = XContentFactory.jsonBuilder().startObject().startObject("type")
|
mapping = XContentFactory.jsonBuilder().startObject().startObject("type")
|
||||||
.startObject("_timestamp").field("enabled", randomBoolean()).startObject("fielddata").field("loading", "eager").field("format", "array").endObject().field("store", "no").endObject()
|
.startObject("_timestamp").field("enabled", enabled).startObject("fielddata").field("loading", "eager").field("format", "array").endObject().field("store", "no").endObject()
|
||||||
.endObject().endObject();
|
.endObject().endObject();
|
||||||
PutMappingResponse putMappingResponse = client().admin().indices().preparePutMapping("test").setType("type").setSource(mapping).get();
|
PutMappingResponse putMappingResponse = client().admin().indices().preparePutMapping("test").setType("type").setSource(mapping).get();
|
||||||
appliedMappings = client().admin().indices().prepareGetMappings("test").get();
|
appliedMappings = client().admin().indices().prepareGetMappings("test").get();
|
||||||
|
|
Loading…
Reference in New Issue