diff --git a/src/main/java/org/elasticsearch/index/mapper/MapperBuilders.java b/src/main/java/org/elasticsearch/index/mapper/MapperBuilders.java index 478a7f683d1..8770809d43a 100644 --- a/src/main/java/org/elasticsearch/index/mapper/MapperBuilders.java +++ b/src/main/java/org/elasticsearch/index/mapper/MapperBuilders.java @@ -22,6 +22,8 @@ package org.elasticsearch.index.mapper; import org.elasticsearch.common.Nullable; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.index.mapper.core.*; +import org.elasticsearch.index.mapper.geo.GeoPointFieldMapper; +import org.elasticsearch.index.mapper.geo.GeoShapeFieldMapper; import org.elasticsearch.index.mapper.internal.*; import org.elasticsearch.index.mapper.ip.IpFieldMapper; import org.elasticsearch.index.mapper.multifield.MultiFieldMapper; @@ -61,6 +63,10 @@ public final class MapperBuilders { return new UidFieldMapper.Builder(); } + public static SizeFieldMapper.Builder size() { + return new SizeFieldMapper.Builder(); + } + public static VersionFieldMapper.Builder version() { return new VersionFieldMapper.Builder(); } @@ -77,6 +83,14 @@ public final class MapperBuilders { return new TimestampFieldMapper.Builder(); } + public static TTLFieldMapper.Builder ttl() { + return new TTLFieldMapper.Builder(); + } + + public static ParentFieldMapper.Builder parent() { + return new ParentFieldMapper.Builder(); + } + public static BoostFieldMapper.Builder boost(String name) { return new BoostFieldMapper.Builder(name); } @@ -148,4 +162,16 @@ public final class MapperBuilders { public static DoubleFieldMapper.Builder doubleField(String name) { return new DoubleFieldMapper.Builder(name); } + + public static GeoPointFieldMapper.Builder geoPointField(String name) { + return new GeoPointFieldMapper.Builder(name); + } + + public static GeoShapeFieldMapper.Builder geoShapeField(String name) { + return new GeoShapeFieldMapper.Builder(name); + } + + public static CompletionFieldMapper.Builder completionField(String name) { + return new CompletionFieldMapper.Builder(name); + } } diff --git a/src/main/java/org/elasticsearch/index/mapper/core/CompletionFieldMapper.java b/src/main/java/org/elasticsearch/index/mapper/core/CompletionFieldMapper.java index 6ead1de8eac..eed3c156036 100644 --- a/src/main/java/org/elasticsearch/index/mapper/core/CompletionFieldMapper.java +++ b/src/main/java/org/elasticsearch/index/mapper/core/CompletionFieldMapper.java @@ -30,6 +30,7 @@ import org.elasticsearch.ElasticSearchIllegalArgumentException; import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.common.xcontent.XContentFactory; import org.elasticsearch.common.xcontent.XContentParser; +import org.elasticsearch.common.xcontent.XContentParser.NumberType; import org.elasticsearch.index.analysis.NamedAnalyzer; import org.elasticsearch.index.codec.postingsformat.PostingsFormatProvider; import org.elasticsearch.index.fielddata.FieldDataType; @@ -46,7 +47,7 @@ import java.util.Locale; import java.util.Map; import java.util.Set; -import static org.elasticsearch.common.xcontent.XContentParser.NumberType; +import static org.elasticsearch.index.mapper.MapperBuilders.completionField; /** * @@ -134,7 +135,7 @@ public class CompletionFieldMapper extends AbstractFieldMapper { @Override public Mapper.Builder parse(String name, Map node, ParserContext parserContext) throws MapperParsingException { - CompletionFieldMapper.Builder builder = new CompletionFieldMapper.Builder(name); + CompletionFieldMapper.Builder builder = completionField(name); for (Map.Entry entry : node.entrySet()) { String fieldName = entry.getKey(); Object fieldNode = entry.getValue(); diff --git a/src/main/java/org/elasticsearch/index/mapper/geo/GeoPointFieldMapper.java b/src/main/java/org/elasticsearch/index/mapper/geo/GeoPointFieldMapper.java index 402d1e3228b..4c1cfde3fdb 100644 --- a/src/main/java/org/elasticsearch/index/mapper/geo/GeoPointFieldMapper.java +++ b/src/main/java/org/elasticsearch/index/mapper/geo/GeoPointFieldMapper.java @@ -46,8 +46,7 @@ import java.io.IOException; import java.util.Locale; import java.util.Map; -import static org.elasticsearch.index.mapper.MapperBuilders.doubleField; -import static org.elasticsearch.index.mapper.MapperBuilders.stringField; +import static org.elasticsearch.index.mapper.MapperBuilders.*; import static org.elasticsearch.index.mapper.core.TypeParsers.parsePathType; import static org.elasticsearch.index.mapper.core.TypeParsers.parseStore; @@ -197,7 +196,7 @@ public class GeoPointFieldMapper implements Mapper, ArrayValueMapperParser { public static class TypeParser implements Mapper.TypeParser { @Override public Mapper.Builder parse(String name, Map node, ParserContext parserContext) throws MapperParsingException { - Builder builder = new Builder(name); + Builder builder = geoPointField(name); for (Map.Entry entry : node.entrySet()) { String fieldName = Strings.toUnderscoreCase(entry.getKey()); diff --git a/src/main/java/org/elasticsearch/index/mapper/geo/GeoShapeFieldMapper.java b/src/main/java/org/elasticsearch/index/mapper/geo/GeoShapeFieldMapper.java index 5cba94f07ef..0133cb8f7a6 100644 --- a/src/main/java/org/elasticsearch/index/mapper/geo/GeoShapeFieldMapper.java +++ b/src/main/java/org/elasticsearch/index/mapper/geo/GeoShapeFieldMapper.java @@ -47,6 +47,9 @@ import java.io.IOException; import java.util.List; import java.util.Map; +import static org.elasticsearch.index.mapper.MapperBuilders.geoShapeField; + + /** * FieldMapper for indexing {@link com.spatial4j.core.shape.Shape}s. *

@@ -166,7 +169,7 @@ public class GeoShapeFieldMapper extends AbstractFieldMapper { @Override public Mapper.Builder parse(String name, Map node, ParserContext parserContext) throws MapperParsingException { - Builder builder = new Builder(name); + Builder builder = geoShapeField(name); for (Map.Entry entry : node.entrySet()) { String fieldName = Strings.toUnderscoreCase(entry.getKey()); diff --git a/src/main/java/org/elasticsearch/index/mapper/internal/ParentFieldMapper.java b/src/main/java/org/elasticsearch/index/mapper/internal/ParentFieldMapper.java index ad2379884da..40202c8ac55 100644 --- a/src/main/java/org/elasticsearch/index/mapper/internal/ParentFieldMapper.java +++ b/src/main/java/org/elasticsearch/index/mapper/internal/ParentFieldMapper.java @@ -47,6 +47,8 @@ import java.util.ArrayList; import java.util.List; import java.util.Map; +import static org.elasticsearch.index.mapper.MapperBuilders.parent; + /** * */ @@ -105,7 +107,7 @@ public class ParentFieldMapper extends AbstractFieldMapper implements Inter public static class TypeParser implements Mapper.TypeParser { @Override public Mapper.Builder parse(String name, Map node, ParserContext parserContext) throws MapperParsingException { - ParentFieldMapper.Builder builder = new ParentFieldMapper.Builder(); + ParentFieldMapper.Builder builder = parent(); for (Map.Entry entry : node.entrySet()) { String fieldName = Strings.toUnderscoreCase(entry.getKey()); Object fieldNode = entry.getValue(); diff --git a/src/main/java/org/elasticsearch/index/mapper/internal/SizeFieldMapper.java b/src/main/java/org/elasticsearch/index/mapper/internal/SizeFieldMapper.java index d2bf07057d7..4b2e15e761c 100644 --- a/src/main/java/org/elasticsearch/index/mapper/internal/SizeFieldMapper.java +++ b/src/main/java/org/elasticsearch/index/mapper/internal/SizeFieldMapper.java @@ -37,6 +37,7 @@ import java.util.List; import java.util.Map; import static org.elasticsearch.common.xcontent.support.XContentMapValues.nodeBooleanValue; +import static org.elasticsearch.index.mapper.MapperBuilders.size; import static org.elasticsearch.index.mapper.core.TypeParsers.parseStore; public class SizeFieldMapper extends IntegerFieldMapper implements RootMapper { @@ -78,7 +79,7 @@ public class SizeFieldMapper extends IntegerFieldMapper implements RootMapper { public static class TypeParser implements Mapper.TypeParser { @Override public Mapper.Builder parse(String name, Map node, ParserContext parserContext) throws MapperParsingException { - SizeFieldMapper.Builder builder = new SizeFieldMapper.Builder(); + SizeFieldMapper.Builder builder = size(); for (Map.Entry entry : node.entrySet()) { String fieldName = Strings.toUnderscoreCase(entry.getKey()); Object fieldNode = entry.getValue(); diff --git a/src/main/java/org/elasticsearch/index/mapper/internal/TTLFieldMapper.java b/src/main/java/org/elasticsearch/index/mapper/internal/TTLFieldMapper.java index eb55c445628..3b6d25ca1fd 100644 --- a/src/main/java/org/elasticsearch/index/mapper/internal/TTLFieldMapper.java +++ b/src/main/java/org/elasticsearch/index/mapper/internal/TTLFieldMapper.java @@ -44,6 +44,7 @@ import java.util.Map; import static org.elasticsearch.common.xcontent.support.XContentMapValues.nodeBooleanValue; import static org.elasticsearch.common.xcontent.support.XContentMapValues.nodeTimeValue; +import static org.elasticsearch.index.mapper.MapperBuilders.ttl; import static org.elasticsearch.index.mapper.core.TypeParsers.parseField; public class TTLFieldMapper extends LongFieldMapper implements InternalMapper, RootMapper { @@ -95,7 +96,7 @@ public class TTLFieldMapper extends LongFieldMapper implements InternalMapper, R public static class TypeParser implements Mapper.TypeParser { @Override public Mapper.Builder parse(String name, Map node, ParserContext parserContext) throws MapperParsingException { - TTLFieldMapper.Builder builder = new TTLFieldMapper.Builder(); + TTLFieldMapper.Builder builder = ttl(); parseField(builder, builder.name, node, parserContext); for (Map.Entry entry : node.entrySet()) { String fieldName = Strings.toUnderscoreCase(entry.getKey());