Add missing mappers to MapperBuilders.

- completion
 - geo_point
 - geo_shape
 - parent
 - size
 - ttl

Close #4423
This commit is contained in:
Adrien Grand 2013-12-12 09:41:07 +01:00
parent b4d1d899d2
commit 0554f8e875
7 changed files with 42 additions and 9 deletions

View File

@ -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);
}
}

View File

@ -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<String> {
@Override
public Mapper.Builder<?, ?> parse(String name, Map<String, Object> node, ParserContext parserContext) throws MapperParsingException {
CompletionFieldMapper.Builder builder = new CompletionFieldMapper.Builder(name);
CompletionFieldMapper.Builder builder = completionField(name);
for (Map.Entry<String, Object> entry : node.entrySet()) {
String fieldName = entry.getKey();
Object fieldNode = entry.getValue();

View File

@ -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<String, Object> node, ParserContext parserContext) throws MapperParsingException {
Builder builder = new Builder(name);
Builder builder = geoPointField(name);
for (Map.Entry<String, Object> entry : node.entrySet()) {
String fieldName = Strings.toUnderscoreCase(entry.getKey());

View File

@ -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.
* <p/>
@ -166,7 +169,7 @@ public class GeoShapeFieldMapper extends AbstractFieldMapper<String> {
@Override
public Mapper.Builder parse(String name, Map<String, Object> node, ParserContext parserContext) throws MapperParsingException {
Builder builder = new Builder(name);
Builder builder = geoShapeField(name);
for (Map.Entry<String, Object> entry : node.entrySet()) {
String fieldName = Strings.toUnderscoreCase(entry.getKey());

View File

@ -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<Uid> implements Inter
public static class TypeParser implements Mapper.TypeParser {
@Override
public Mapper.Builder parse(String name, Map<String, Object> node, ParserContext parserContext) throws MapperParsingException {
ParentFieldMapper.Builder builder = new ParentFieldMapper.Builder();
ParentFieldMapper.Builder builder = parent();
for (Map.Entry<String, Object> entry : node.entrySet()) {
String fieldName = Strings.toUnderscoreCase(entry.getKey());
Object fieldNode = entry.getValue();

View File

@ -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<String, Object> node, ParserContext parserContext) throws MapperParsingException {
SizeFieldMapper.Builder builder = new SizeFieldMapper.Builder();
SizeFieldMapper.Builder builder = size();
for (Map.Entry<String, Object> entry : node.entrySet()) {
String fieldName = Strings.toUnderscoreCase(entry.getKey());
Object fieldNode = entry.getValue();

View File

@ -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<String, Object> node, ParserContext parserContext) throws MapperParsingException {
TTLFieldMapper.Builder builder = new TTLFieldMapper.Builder();
TTLFieldMapper.Builder builder = ttl();
parseField(builder, builder.name, node, parserContext);
for (Map.Entry<String, Object> entry : node.entrySet()) {
String fieldName = Strings.toUnderscoreCase(entry.getKey());