From cf998e2f89b912f6ef73970b8bc76f125f165bd1 Mon Sep 17 00:00:00 2001 From: kimchy Date: Thu, 15 Jul 2010 22:35:18 +0300 Subject: [PATCH] protected when not of the same type mapper when merging --- .../index/mapper/xcontent/XContentDateFieldMapper.java | 3 +++ .../index/mapper/xcontent/XContentDoubleFieldMapper.java | 3 +++ .../index/mapper/xcontent/XContentFloatFieldMapper.java | 3 +++ .../index/mapper/xcontent/XContentIntegerFieldMapper.java | 3 +++ .../index/mapper/xcontent/XContentLongFieldMapper.java | 3 +++ .../index/mapper/xcontent/XContentNumberFieldMapper.java | 3 +++ .../index/mapper/xcontent/XContentShortFieldMapper.java | 3 +++ .../index/mapper/xcontent/XContentStringFieldMapper.java | 3 +++ 8 files changed, 24 insertions(+) diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/index/mapper/xcontent/XContentDateFieldMapper.java b/modules/elasticsearch/src/main/java/org/elasticsearch/index/mapper/xcontent/XContentDateFieldMapper.java index 389301122d3..ef773b5c73f 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/index/mapper/xcontent/XContentDateFieldMapper.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/index/mapper/xcontent/XContentDateFieldMapper.java @@ -216,6 +216,9 @@ public class XContentDateFieldMapper extends XContentNumberFieldMapper { @Override public void merge(XContentMapper mergeWith, MergeContext mergeContext) throws MergeMappingException { super.merge(mergeWith, mergeContext); + if (!this.getClass().equals(mergeWith.getClass())) { + return; + } if (!mergeContext.mergeFlags().simulate()) { this.nullValue = ((XContentDateFieldMapper) mergeWith).nullValue; } diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/index/mapper/xcontent/XContentDoubleFieldMapper.java b/modules/elasticsearch/src/main/java/org/elasticsearch/index/mapper/xcontent/XContentDoubleFieldMapper.java index e2c357bbd15..130c3ecf8a5 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/index/mapper/xcontent/XContentDoubleFieldMapper.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/index/mapper/xcontent/XContentDoubleFieldMapper.java @@ -198,6 +198,9 @@ public class XContentDoubleFieldMapper extends XContentNumberFieldMapper @Override public void merge(XContentMapper mergeWith, MergeContext mergeContext) throws MergeMappingException { super.merge(mergeWith, mergeContext); + if (!this.getClass().equals(mergeWith.getClass())) { + return; + } if (!mergeContext.mergeFlags().simulate()) { this.nullValue = ((XContentDoubleFieldMapper) mergeWith).nullValue; this.nullValueAsString = ((XContentDoubleFieldMapper) mergeWith).nullValueAsString; diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/index/mapper/xcontent/XContentFloatFieldMapper.java b/modules/elasticsearch/src/main/java/org/elasticsearch/index/mapper/xcontent/XContentFloatFieldMapper.java index 9a40b911caa..550aa5587bf 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/index/mapper/xcontent/XContentFloatFieldMapper.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/index/mapper/xcontent/XContentFloatFieldMapper.java @@ -197,6 +197,9 @@ public class XContentFloatFieldMapper extends XContentNumberFieldMapper { @Override public void merge(XContentMapper mergeWith, MergeContext mergeContext) throws MergeMappingException { super.merge(mergeWith, mergeContext); + if (!this.getClass().equals(mergeWith.getClass())) { + return; + } if (!mergeContext.mergeFlags().simulate()) { this.nullValue = ((XContentFloatFieldMapper) mergeWith).nullValue; this.nullValueAsString = ((XContentFloatFieldMapper) mergeWith).nullValueAsString; diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/index/mapper/xcontent/XContentIntegerFieldMapper.java b/modules/elasticsearch/src/main/java/org/elasticsearch/index/mapper/xcontent/XContentIntegerFieldMapper.java index 30d2a3ef95f..385d7305e96 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/index/mapper/xcontent/XContentIntegerFieldMapper.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/index/mapper/xcontent/XContentIntegerFieldMapper.java @@ -197,6 +197,9 @@ public class XContentIntegerFieldMapper extends XContentNumberFieldMapper { @Override public void merge(XContentMapper mergeWith, MergeContext mergeContext) throws MergeMappingException { super.merge(mergeWith, mergeContext); + if (!this.getClass().equals(mergeWith.getClass())) { + return; + } if (!mergeContext.mergeFlags().simulate()) { this.nullValue = ((XContentLongFieldMapper) mergeWith).nullValue; this.nullValueAsString = ((XContentLongFieldMapper) mergeWith).nullValueAsString; diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/index/mapper/xcontent/XContentNumberFieldMapper.java b/modules/elasticsearch/src/main/java/org/elasticsearch/index/mapper/xcontent/XContentNumberFieldMapper.java index 99911da1c30..9819a1bf74b 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/index/mapper/xcontent/XContentNumberFieldMapper.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/index/mapper/xcontent/XContentNumberFieldMapper.java @@ -159,6 +159,9 @@ public abstract class XContentNumberFieldMapper extends XConte @Override public void merge(XContentMapper mergeWith, MergeContext mergeContext) throws MergeMappingException { super.merge(mergeWith, mergeContext); + if (!this.getClass().equals(mergeWith.getClass())) { + return; + } if (!mergeContext.mergeFlags().simulate()) { this.precisionStep = ((XContentNumberFieldMapper) mergeWith).precisionStep; this.includeInAll = ((XContentNumberFieldMapper) mergeWith).includeInAll; diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/index/mapper/xcontent/XContentShortFieldMapper.java b/modules/elasticsearch/src/main/java/org/elasticsearch/index/mapper/xcontent/XContentShortFieldMapper.java index f75c71c47a0..84a5810324d 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/index/mapper/xcontent/XContentShortFieldMapper.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/index/mapper/xcontent/XContentShortFieldMapper.java @@ -197,6 +197,9 @@ public class XContentShortFieldMapper extends XContentNumberFieldMapper { @Override public void merge(XContentMapper mergeWith, MergeContext mergeContext) throws MergeMappingException { super.merge(mergeWith, mergeContext); + if (!this.getClass().equals(mergeWith.getClass())) { + return; + } if (!mergeContext.mergeFlags().simulate()) { this.nullValue = ((XContentShortFieldMapper) mergeWith).nullValue; this.nullValueAsString = ((XContentShortFieldMapper) mergeWith).nullValueAsString; diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/index/mapper/xcontent/XContentStringFieldMapper.java b/modules/elasticsearch/src/main/java/org/elasticsearch/index/mapper/xcontent/XContentStringFieldMapper.java index d8fdaecafc3..ea9dc231e0a 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/index/mapper/xcontent/XContentStringFieldMapper.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/index/mapper/xcontent/XContentStringFieldMapper.java @@ -151,6 +151,9 @@ public class XContentStringFieldMapper extends XContentFieldMapper imple @Override public void merge(XContentMapper mergeWith, MergeContext mergeContext) throws MergeMappingException { super.merge(mergeWith, mergeContext); + if (!this.getClass().equals(mergeWith.getClass())) { + return; + } if (!mergeContext.mergeFlags().simulate()) { this.includeInAll = ((XContentStringFieldMapper) mergeWith).includeInAll; this.nullValue = ((XContentStringFieldMapper) mergeWith).nullValue;