rename xonctent mappers to just mappers
This commit is contained in:
parent
af3599fe47
commit
523a8b4c3e
|
@ -29,7 +29,7 @@ import org.elasticsearch.index.field.data.FieldDataType;
|
|||
import org.elasticsearch.index.field.data.NumericFieldData;
|
||||
import org.elasticsearch.index.mapper.FieldMapper;
|
||||
import org.elasticsearch.index.mapper.MapperService;
|
||||
import org.elasticsearch.index.mapper.xcontent.XContentGeoPointFieldMapper;
|
||||
import org.elasticsearch.index.mapper.xcontent.GeoPointFieldMapper;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
|
@ -113,13 +113,13 @@ public class GeoDistanceDataComparator extends FieldComparator {
|
|||
this.geoDistance = geoDistance;
|
||||
this.fieldDataCache = fieldDataCache;
|
||||
|
||||
FieldMapper mapper = mapperService.smartNameFieldMapper(fieldName + XContentGeoPointFieldMapper.Names.LAT_SUFFIX);
|
||||
FieldMapper mapper = mapperService.smartNameFieldMapper(fieldName + GeoPointFieldMapper.Names.LAT_SUFFIX);
|
||||
if (mapper == null) {
|
||||
throw new ElasticSearchIllegalArgumentException("No mapping found for field [" + fieldName + "] for geo distance sort");
|
||||
}
|
||||
this.indexLatFieldName = mapper.names().indexName();
|
||||
|
||||
mapper = mapperService.smartNameFieldMapper(fieldName + XContentGeoPointFieldMapper.Names.LON_SUFFIX);
|
||||
mapper = mapperService.smartNameFieldMapper(fieldName + GeoPointFieldMapper.Names.LON_SUFFIX);
|
||||
if (mapper == null) {
|
||||
throw new ElasticSearchIllegalArgumentException("No mapping found for field [" + fieldName + "] for geo distance sort");
|
||||
}
|
||||
|
|
|
@ -39,7 +39,7 @@ import java.io.IOException;
|
|||
/**
|
||||
* @author kimchy (shay.banon)
|
||||
*/
|
||||
public abstract class XContentFieldMapper<T> implements FieldMapper<T>, XContentMapper {
|
||||
public abstract class AbstractFieldMapper<T> implements FieldMapper<T>, XContentMapper {
|
||||
|
||||
public static class Defaults {
|
||||
public static final Field.Index INDEX = Field.Index.ANALYZED;
|
||||
|
@ -50,7 +50,7 @@ public abstract class XContentFieldMapper<T> implements FieldMapper<T>, XContent
|
|||
public static final boolean OMIT_TERM_FREQ_AND_POSITIONS = false;
|
||||
}
|
||||
|
||||
public abstract static class OpenBuilder<T extends Builder, Y extends XContentFieldMapper> extends XContentFieldMapper.Builder<T, Y> {
|
||||
public abstract static class OpenBuilder<T extends Builder, Y extends AbstractFieldMapper> extends AbstractFieldMapper.Builder<T, Y> {
|
||||
|
||||
protected OpenBuilder(String name) {
|
||||
super(name);
|
||||
|
@ -93,7 +93,7 @@ public abstract class XContentFieldMapper<T> implements FieldMapper<T>, XContent
|
|||
}
|
||||
}
|
||||
|
||||
public abstract static class Builder<T extends Builder, Y extends XContentFieldMapper> extends XContentMapper.Builder<T, Y> {
|
||||
public abstract static class Builder<T extends Builder, Y extends AbstractFieldMapper> extends XContentMapper.Builder<T, Y> {
|
||||
|
||||
protected Field.Index index = Defaults.INDEX;
|
||||
|
||||
|
@ -204,7 +204,7 @@ public abstract class XContentFieldMapper<T> implements FieldMapper<T>, XContent
|
|||
|
||||
protected final NamedAnalyzer searchAnalyzer;
|
||||
|
||||
protected XContentFieldMapper(Names names, Field.Index index, Field.Store store, Field.TermVector termVector,
|
||||
protected AbstractFieldMapper(Names names, Field.Index index, Field.Store store, Field.TermVector termVector,
|
||||
float boost, boolean omitNorms, boolean omitTermFreqAndPositions, NamedAnalyzer indexAnalyzer, NamedAnalyzer searchAnalyzer) {
|
||||
this.names = names;
|
||||
this.index = index;
|
||||
|
@ -341,14 +341,14 @@ public abstract class XContentFieldMapper<T> implements FieldMapper<T>, XContent
|
|||
@Override public void merge(XContentMapper mergeWith, MergeContext mergeContext) throws MergeMappingException {
|
||||
if (!this.getClass().equals(mergeWith.getClass())) {
|
||||
String mergedType = mergeWith.getClass().getSimpleName();
|
||||
if (mergeWith instanceof XContentFieldMapper) {
|
||||
mergedType = ((XContentFieldMapper) mergeWith).contentType();
|
||||
if (mergeWith instanceof AbstractFieldMapper) {
|
||||
mergedType = ((AbstractFieldMapper) mergeWith).contentType();
|
||||
}
|
||||
mergeContext.addConflict("mapper [" + names.fullName() + "] of different type, current_type [" + contentType() + "], merged_type [" + mergedType + "]");
|
||||
// different types, return
|
||||
return;
|
||||
}
|
||||
XContentFieldMapper fieldMergeWith = (XContentFieldMapper) mergeWith;
|
||||
AbstractFieldMapper fieldMergeWith = (AbstractFieldMapper) mergeWith;
|
||||
if (!this.index.equals(fieldMergeWith.index)) {
|
||||
mergeContext.addConflict("mapper [" + names.fullName() + "] has different index values");
|
||||
}
|
|
@ -29,7 +29,6 @@ import org.elasticsearch.common.lucene.all.AllField;
|
|||
import org.elasticsearch.common.lucene.all.AllTermQuery;
|
||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||
import org.elasticsearch.index.analysis.NamedAnalyzer;
|
||||
import org.elasticsearch.index.mapper.AllFieldMapper;
|
||||
import org.elasticsearch.index.mapper.DocumentMapper;
|
||||
import org.elasticsearch.index.mapper.MergeMappingException;
|
||||
|
||||
|
@ -38,18 +37,18 @@ import java.io.IOException;
|
|||
/**
|
||||
* @author kimchy (shay.banon)
|
||||
*/
|
||||
public class XContentAllFieldMapper extends XContentFieldMapper<Void> implements AllFieldMapper {
|
||||
public class AllFieldMapper extends AbstractFieldMapper<Void> implements org.elasticsearch.index.mapper.AllFieldMapper {
|
||||
|
||||
public static final String CONTENT_TYPE = "_all";
|
||||
|
||||
public static class Defaults extends XContentFieldMapper.Defaults {
|
||||
public static final String NAME = AllFieldMapper.NAME;
|
||||
public static final String INDEX_NAME = AllFieldMapper.NAME;
|
||||
public static class Defaults extends AbstractFieldMapper.Defaults {
|
||||
public static final String NAME = org.elasticsearch.index.mapper.AllFieldMapper.NAME;
|
||||
public static final String INDEX_NAME = org.elasticsearch.index.mapper.AllFieldMapper.NAME;
|
||||
public static final boolean ENABLED = true;
|
||||
}
|
||||
|
||||
|
||||
public static class Builder extends XContentFieldMapper.Builder<Builder, XContentAllFieldMapper> {
|
||||
public static class Builder extends AbstractFieldMapper.Builder<Builder, AllFieldMapper> {
|
||||
|
||||
private boolean enabled = Defaults.ENABLED;
|
||||
|
||||
|
@ -80,8 +79,8 @@ public class XContentAllFieldMapper extends XContentFieldMapper<Void> implements
|
|||
return super.searchAnalyzer(searchAnalyzer);
|
||||
}
|
||||
|
||||
@Override public XContentAllFieldMapper build(BuilderContext context) {
|
||||
return new XContentAllFieldMapper(name, store, termVector, omitNorms, omitTermFreqAndPositions,
|
||||
@Override public AllFieldMapper build(BuilderContext context) {
|
||||
return new AllFieldMapper(name, store, termVector, omitNorms, omitTermFreqAndPositions,
|
||||
indexAnalyzer, searchAnalyzer, enabled);
|
||||
}
|
||||
}
|
||||
|
@ -89,12 +88,12 @@ public class XContentAllFieldMapper extends XContentFieldMapper<Void> implements
|
|||
|
||||
private boolean enabled;
|
||||
|
||||
public XContentAllFieldMapper() {
|
||||
public AllFieldMapper() {
|
||||
this(Defaults.NAME, Defaults.STORE, Defaults.TERM_VECTOR, Defaults.OMIT_NORMS, Defaults.OMIT_TERM_FREQ_AND_POSITIONS, null, null, Defaults.ENABLED);
|
||||
}
|
||||
|
||||
protected XContentAllFieldMapper(String name, Field.Store store, Field.TermVector termVector, boolean omitNorms, boolean omitTermFreqAndPositions,
|
||||
NamedAnalyzer indexAnalyzer, NamedAnalyzer searchAnalyzer, boolean enabled) {
|
||||
protected AllFieldMapper(String name, Field.Store store, Field.TermVector termVector, boolean omitNorms, boolean omitTermFreqAndPositions,
|
||||
NamedAnalyzer indexAnalyzer, NamedAnalyzer searchAnalyzer, boolean enabled) {
|
||||
super(new Names(name, name, name, name), Field.Index.ANALYZED, store, termVector, 1.0f, omitNorms, omitTermFreqAndPositions,
|
||||
indexAnalyzer, searchAnalyzer);
|
||||
this.enabled = enabled;
|
|
@ -25,5 +25,5 @@ package org.elasticsearch.index.mapper.xcontent;
|
|||
*
|
||||
* @author kimchy (shay.banon)
|
||||
*/
|
||||
public interface XContentArrayValueMapperParser {
|
||||
public interface ArrayValueMapperParser {
|
||||
}
|
|
@ -34,11 +34,11 @@ import static org.elasticsearch.index.mapper.xcontent.XContentTypeParsers.*;
|
|||
/**
|
||||
* @author kimchy (shay.banon)
|
||||
*/
|
||||
public class XContentBinaryFieldMapper extends XContentFieldMapper<byte[]> {
|
||||
public class BinaryFieldMapper extends AbstractFieldMapper<byte[]> {
|
||||
|
||||
public static final String CONTENT_TYPE = "binary";
|
||||
|
||||
public static class Builder extends XContentFieldMapper.Builder<Builder, XContentBinaryFieldMapper> {
|
||||
public static class Builder extends AbstractFieldMapper.Builder<Builder, BinaryFieldMapper> {
|
||||
|
||||
public Builder(String name) {
|
||||
super(name);
|
||||
|
@ -49,20 +49,20 @@ public class XContentBinaryFieldMapper extends XContentFieldMapper<byte[]> {
|
|||
return super.indexName(indexName);
|
||||
}
|
||||
|
||||
@Override public XContentBinaryFieldMapper build(BuilderContext context) {
|
||||
return new XContentBinaryFieldMapper(buildNames(context));
|
||||
@Override public BinaryFieldMapper build(BuilderContext context) {
|
||||
return new BinaryFieldMapper(buildNames(context));
|
||||
}
|
||||
}
|
||||
|
||||
public static class TypeParser implements XContentTypeParser {
|
||||
public static class TypeParser implements XContentMapper.TypeParser {
|
||||
@Override public XContentMapper.Builder parse(String name, Map<String, Object> node, ParserContext parserContext) throws MapperParsingException {
|
||||
XContentBinaryFieldMapper.Builder builder = binaryField(name);
|
||||
BinaryFieldMapper.Builder builder = binaryField(name);
|
||||
parseField(builder, name, node, parserContext);
|
||||
return builder;
|
||||
}
|
||||
}
|
||||
|
||||
protected XContentBinaryFieldMapper(Names names) {
|
||||
protected BinaryFieldMapper(Names names) {
|
||||
super(names, Field.Index.NO, Field.Store.YES, Field.TermVector.NO, 1.0f, true, true, null, null);
|
||||
}
|
||||
|
|
@ -39,16 +39,16 @@ import static org.elasticsearch.index.mapper.xcontent.XContentTypeParsers.*;
|
|||
* @author kimchy (shay.banon)
|
||||
*/
|
||||
// TODO this can be made better, maybe storing a byte for it?
|
||||
public class XContentBooleanFieldMapper extends XContentFieldMapper<Boolean> {
|
||||
public class BooleanFieldMapper extends AbstractFieldMapper<Boolean> {
|
||||
|
||||
public static final String CONTENT_TYPE = "boolean";
|
||||
|
||||
public static class Defaults extends XContentFieldMapper.Defaults {
|
||||
public static class Defaults extends AbstractFieldMapper.Defaults {
|
||||
public static final boolean OMIT_NORMS = true;
|
||||
public static final Boolean NULL_VALUE = null;
|
||||
}
|
||||
|
||||
public static class Builder extends XContentFieldMapper.Builder<Builder, XContentBooleanFieldMapper> {
|
||||
public static class Builder extends AbstractFieldMapper.Builder<Builder, BooleanFieldMapper> {
|
||||
|
||||
private Boolean nullValue = Defaults.NULL_VALUE;
|
||||
|
||||
|
@ -87,15 +87,15 @@ public class XContentBooleanFieldMapper extends XContentFieldMapper<Boolean> {
|
|||
return super.omitTermFreqAndPositions(omitTermFreqAndPositions);
|
||||
}
|
||||
|
||||
@Override public XContentBooleanFieldMapper build(BuilderContext context) {
|
||||
return new XContentBooleanFieldMapper(buildNames(context), index, store,
|
||||
@Override public BooleanFieldMapper build(BuilderContext context) {
|
||||
return new BooleanFieldMapper(buildNames(context), index, store,
|
||||
termVector, boost, omitNorms, omitTermFreqAndPositions, nullValue);
|
||||
}
|
||||
}
|
||||
|
||||
public static class TypeParser implements XContentTypeParser {
|
||||
public static class TypeParser implements XContentMapper.TypeParser {
|
||||
@Override public XContentMapper.Builder parse(String name, Map<String, Object> node, ParserContext parserContext) throws MapperParsingException {
|
||||
XContentBooleanFieldMapper.Builder builder = booleanField(name);
|
||||
BooleanFieldMapper.Builder builder = booleanField(name);
|
||||
parseField(builder, name, node, parserContext);
|
||||
for (Map.Entry<String, Object> entry : node.entrySet()) {
|
||||
String propName = Strings.toUnderscoreCase(entry.getKey());
|
||||
|
@ -110,8 +110,8 @@ public class XContentBooleanFieldMapper extends XContentFieldMapper<Boolean> {
|
|||
|
||||
private Boolean nullValue;
|
||||
|
||||
protected XContentBooleanFieldMapper(Names names, Field.Index index, Field.Store store, Field.TermVector termVector,
|
||||
float boost, boolean omitNorms, boolean omitTermFreqAndPositions, Boolean nullValue) {
|
||||
protected BooleanFieldMapper(Names names, Field.Index index, Field.Store store, Field.TermVector termVector,
|
||||
float boost, boolean omitNorms, boolean omitTermFreqAndPositions, Boolean nullValue) {
|
||||
super(names, index, store, termVector, boost, omitNorms, omitTermFreqAndPositions, Lucene.KEYWORD_ANALYZER, Lucene.KEYWORD_ANALYZER);
|
||||
this.nullValue = nullValue;
|
||||
}
|
|
@ -32,7 +32,6 @@ import org.elasticsearch.common.xcontent.XContentParser;
|
|||
import org.elasticsearch.index.analysis.NamedAnalyzer;
|
||||
import org.elasticsearch.index.analysis.NumericFloatAnalyzer;
|
||||
import org.elasticsearch.index.field.data.FieldDataType;
|
||||
import org.elasticsearch.index.mapper.BoostFieldMapper;
|
||||
import org.elasticsearch.index.mapper.MergeMappingException;
|
||||
|
||||
import java.io.IOException;
|
||||
|
@ -40,18 +39,18 @@ import java.io.IOException;
|
|||
/**
|
||||
* @author kimchy (shay.banon)
|
||||
*/
|
||||
public class XContentBoostFieldMapper extends XContentNumberFieldMapper<Float> implements BoostFieldMapper {
|
||||
public class BoostFieldMapper extends NumberFieldMapper<Float> implements org.elasticsearch.index.mapper.BoostFieldMapper {
|
||||
|
||||
public static final String CONTENT_TYPE = "_boost";
|
||||
|
||||
public static class Defaults extends XContentNumberFieldMapper.Defaults {
|
||||
public static class Defaults extends NumberFieldMapper.Defaults {
|
||||
public static final String NAME = "_boost";
|
||||
public static final Float NULL_VALUE = null;
|
||||
public static final Field.Index INDEX = Field.Index.NO;
|
||||
public static final Field.Store STORE = Field.Store.NO;
|
||||
}
|
||||
|
||||
public static class Builder extends XContentNumberFieldMapper.Builder<Builder, XContentBoostFieldMapper> {
|
||||
public static class Builder extends NumberFieldMapper.Builder<Builder, BoostFieldMapper> {
|
||||
|
||||
protected Float nullValue = Defaults.NULL_VALUE;
|
||||
|
||||
|
@ -67,8 +66,8 @@ public class XContentBoostFieldMapper extends XContentNumberFieldMapper<Float> i
|
|||
return this;
|
||||
}
|
||||
|
||||
@Override public XContentBoostFieldMapper build(BuilderContext context) {
|
||||
return new XContentBoostFieldMapper(name, buildIndexName(context),
|
||||
@Override public BoostFieldMapper build(BuilderContext context) {
|
||||
return new BoostFieldMapper(name, buildIndexName(context),
|
||||
precisionStep, index, store, boost, omitNorms, omitTermFreqAndPositions, nullValue);
|
||||
}
|
||||
}
|
||||
|
@ -76,18 +75,18 @@ public class XContentBoostFieldMapper extends XContentNumberFieldMapper<Float> i
|
|||
|
||||
private final Float nullValue;
|
||||
|
||||
protected XContentBoostFieldMapper() {
|
||||
protected BoostFieldMapper() {
|
||||
this(Defaults.NAME, Defaults.NAME);
|
||||
}
|
||||
|
||||
protected XContentBoostFieldMapper(String name, String indexName) {
|
||||
protected BoostFieldMapper(String name, String indexName) {
|
||||
this(name, indexName, Defaults.PRECISION_STEP, Defaults.INDEX, Defaults.STORE,
|
||||
Defaults.BOOST, Defaults.OMIT_NORMS, Defaults.OMIT_TERM_FREQ_AND_POSITIONS, Defaults.NULL_VALUE);
|
||||
}
|
||||
|
||||
protected XContentBoostFieldMapper(String name, String indexName, int precisionStep, Field.Index index, Field.Store store,
|
||||
float boost, boolean omitNorms, boolean omitTermFreqAndPositions,
|
||||
Float nullValue) {
|
||||
protected BoostFieldMapper(String name, String indexName, int precisionStep, Field.Index index, Field.Store store,
|
||||
float boost, boolean omitNorms, boolean omitTermFreqAndPositions,
|
||||
Float nullValue) {
|
||||
super(new Names(name, indexName, indexName, name), precisionStep, index, store, boost, omitNorms, omitTermFreqAndPositions,
|
||||
new NamedAnalyzer("_float/" + precisionStep, new NumericFloatAnalyzer(precisionStep)),
|
||||
new NamedAnalyzer("_float/max", new NumericFloatAnalyzer(Integer.MAX_VALUE)));
|
|
@ -47,17 +47,17 @@ import static org.elasticsearch.index.mapper.xcontent.XContentTypeParsers.*;
|
|||
/**
|
||||
* @author kimchy (shay.banon)
|
||||
*/
|
||||
public class XContentDateFieldMapper extends XContentNumberFieldMapper<Long> {
|
||||
public class DateFieldMapper extends NumberFieldMapper<Long> {
|
||||
|
||||
public static final String CONTENT_TYPE = "date";
|
||||
|
||||
public static class Defaults extends XContentNumberFieldMapper.Defaults {
|
||||
public static class Defaults extends NumberFieldMapper.Defaults {
|
||||
public static final FormatDateTimeFormatter DATE_TIME_FORMATTER = Joda.forPattern("dateOptionalTime");
|
||||
|
||||
public static final String NULL_VALUE = null;
|
||||
}
|
||||
|
||||
public static class Builder extends XContentNumberFieldMapper.Builder<Builder, XContentDateFieldMapper> {
|
||||
public static class Builder extends NumberFieldMapper.Builder<Builder, DateFieldMapper> {
|
||||
|
||||
protected String nullValue = Defaults.NULL_VALUE;
|
||||
|
||||
|
@ -78,17 +78,17 @@ public class XContentDateFieldMapper extends XContentNumberFieldMapper<Long> {
|
|||
return this;
|
||||
}
|
||||
|
||||
@Override public XContentDateFieldMapper build(BuilderContext context) {
|
||||
XContentDateFieldMapper fieldMapper = new XContentDateFieldMapper(buildNames(context), dateTimeFormatter,
|
||||
@Override public DateFieldMapper build(BuilderContext context) {
|
||||
DateFieldMapper fieldMapper = new DateFieldMapper(buildNames(context), dateTimeFormatter,
|
||||
precisionStep, index, store, boost, omitNorms, omitTermFreqAndPositions, nullValue);
|
||||
fieldMapper.includeInAll(includeInAll);
|
||||
return fieldMapper;
|
||||
}
|
||||
}
|
||||
|
||||
public static class TypeParser implements XContentTypeParser {
|
||||
public static class TypeParser implements XContentMapper.TypeParser {
|
||||
@Override public XContentMapper.Builder parse(String name, Map<String, Object> node, ParserContext parserContext) throws MapperParsingException {
|
||||
XContentDateFieldMapper.Builder builder = dateField(name);
|
||||
DateFieldMapper.Builder builder = dateField(name);
|
||||
parseNumberField(builder, name, node, parserContext);
|
||||
for (Map.Entry<String, Object> entry : node.entrySet()) {
|
||||
String propName = Strings.toUnderscoreCase(entry.getKey());
|
||||
|
@ -107,10 +107,10 @@ public class XContentDateFieldMapper extends XContentNumberFieldMapper<Long> {
|
|||
|
||||
private String nullValue;
|
||||
|
||||
protected XContentDateFieldMapper(Names names, FormatDateTimeFormatter dateTimeFormatter, int precisionStep,
|
||||
Field.Index index, Field.Store store,
|
||||
float boost, boolean omitNorms, boolean omitTermFreqAndPositions,
|
||||
String nullValue) {
|
||||
protected DateFieldMapper(Names names, FormatDateTimeFormatter dateTimeFormatter, int precisionStep,
|
||||
Field.Index index, Field.Store store,
|
||||
float boost, boolean omitNorms, boolean omitTermFreqAndPositions,
|
||||
String nullValue) {
|
||||
super(names, precisionStep, index, store, boost, omitNorms, omitTermFreqAndPositions,
|
||||
new NamedAnalyzer("_date/" + precisionStep, new NumericDateAnalyzer(precisionStep, dateTimeFormatter.parser())),
|
||||
new NamedAnalyzer("_date/max", new NumericDateAnalyzer(Integer.MAX_VALUE, dateTimeFormatter.parser())));
|
||||
|
@ -216,7 +216,7 @@ public class XContentDateFieldMapper extends XContentNumberFieldMapper<Long> {
|
|||
return;
|
||||
}
|
||||
if (!mergeContext.mergeFlags().simulate()) {
|
||||
this.nullValue = ((XContentDateFieldMapper) mergeWith).nullValue;
|
||||
this.nullValue = ((DateFieldMapper) mergeWith).nullValue;
|
||||
}
|
||||
}
|
||||
|
|
@ -45,15 +45,15 @@ import static org.elasticsearch.index.mapper.xcontent.XContentTypeParsers.*;
|
|||
/**
|
||||
* @author kimchy (shay.banon)
|
||||
*/
|
||||
public class XContentDoubleFieldMapper extends XContentNumberFieldMapper<Double> {
|
||||
public class DoubleFieldMapper extends NumberFieldMapper<Double> {
|
||||
|
||||
public static final String CONTENT_TYPE = "double";
|
||||
|
||||
public static class Defaults extends XContentNumberFieldMapper.Defaults {
|
||||
public static class Defaults extends NumberFieldMapper.Defaults {
|
||||
public static final Double NULL_VALUE = null;
|
||||
}
|
||||
|
||||
public static class Builder extends XContentNumberFieldMapper.Builder<Builder, XContentDoubleFieldMapper> {
|
||||
public static class Builder extends NumberFieldMapper.Builder<Builder, DoubleFieldMapper> {
|
||||
|
||||
protected Double nullValue = Defaults.NULL_VALUE;
|
||||
|
||||
|
@ -67,17 +67,17 @@ public class XContentDoubleFieldMapper extends XContentNumberFieldMapper<Double>
|
|||
return this;
|
||||
}
|
||||
|
||||
@Override public XContentDoubleFieldMapper build(BuilderContext context) {
|
||||
XContentDoubleFieldMapper fieldMapper = new XContentDoubleFieldMapper(buildNames(context),
|
||||
@Override public DoubleFieldMapper build(BuilderContext context) {
|
||||
DoubleFieldMapper fieldMapper = new DoubleFieldMapper(buildNames(context),
|
||||
precisionStep, index, store, boost, omitNorms, omitTermFreqAndPositions, nullValue);
|
||||
fieldMapper.includeInAll(includeInAll);
|
||||
return fieldMapper;
|
||||
}
|
||||
}
|
||||
|
||||
public static class TypeParser implements XContentTypeParser {
|
||||
public static class TypeParser implements XContentMapper.TypeParser {
|
||||
@Override public XContentMapper.Builder parse(String name, Map<String, Object> node, ParserContext parserContext) throws MapperParsingException {
|
||||
XContentDoubleFieldMapper.Builder builder = doubleField(name);
|
||||
DoubleFieldMapper.Builder builder = doubleField(name);
|
||||
parseNumberField(builder, name, node, parserContext);
|
||||
for (Map.Entry<String, Object> entry : node.entrySet()) {
|
||||
String propName = entry.getKey();
|
||||
|
@ -95,10 +95,10 @@ public class XContentDoubleFieldMapper extends XContentNumberFieldMapper<Double>
|
|||
|
||||
private String nullValueAsString;
|
||||
|
||||
protected XContentDoubleFieldMapper(Names names, int precisionStep,
|
||||
Field.Index index, Field.Store store,
|
||||
float boost, boolean omitNorms, boolean omitTermFreqAndPositions,
|
||||
Double nullValue) {
|
||||
protected DoubleFieldMapper(Names names, int precisionStep,
|
||||
Field.Index index, Field.Store store,
|
||||
float boost, boolean omitNorms, boolean omitTermFreqAndPositions,
|
||||
Double nullValue) {
|
||||
super(names, precisionStep, index, store, boost, omitNorms, omitTermFreqAndPositions,
|
||||
new NamedAnalyzer("_double/" + precisionStep, new NumericDoubleAnalyzer(precisionStep)),
|
||||
new NamedAnalyzer("_double/max", new NumericDoubleAnalyzer(Integer.MAX_VALUE)));
|
||||
|
@ -198,8 +198,8 @@ public class XContentDoubleFieldMapper extends XContentNumberFieldMapper<Double>
|
|||
return;
|
||||
}
|
||||
if (!mergeContext.mergeFlags().simulate()) {
|
||||
this.nullValue = ((XContentDoubleFieldMapper) mergeWith).nullValue;
|
||||
this.nullValueAsString = ((XContentDoubleFieldMapper) mergeWith).nullValueAsString;
|
||||
this.nullValue = ((DoubleFieldMapper) mergeWith).nullValue;
|
||||
this.nullValueAsString = ((DoubleFieldMapper) mergeWith).nullValueAsString;
|
||||
}
|
||||
}
|
||||
|
|
@ -31,7 +31,7 @@ import java.util.Map;
|
|||
/**
|
||||
* @author kimchy (shay.banon)
|
||||
*/
|
||||
public class XContentDynamicTemplate {
|
||||
public class DynamicTemplate {
|
||||
|
||||
public static enum MatchType {
|
||||
SIMPLE,
|
||||
|
@ -59,7 +59,7 @@ public class XContentDynamicTemplate {
|
|||
|
||||
private final Map<String, Object> mapping;
|
||||
|
||||
public static XContentDynamicTemplate parse(Map<String, Object> conf) throws MapperParsingException {
|
||||
public static DynamicTemplate parse(Map<String, Object> conf) throws MapperParsingException {
|
||||
if (!conf.containsKey("match")) {
|
||||
throw new MapperParsingException("template must have match set");
|
||||
}
|
||||
|
@ -71,10 +71,10 @@ public class XContentDynamicTemplate {
|
|||
}
|
||||
Map<String, Object> mapping = (Map<String, Object>) conf.get("mapping");
|
||||
String matchType = conf.containsKey("match_pattern") ? conf.get("match_pattern").toString() : "simple";
|
||||
return new XContentDynamicTemplate(conf, match, unmatch, matchMappingType, MatchType.fromString(matchType), mapping);
|
||||
return new DynamicTemplate(conf, match, unmatch, matchMappingType, MatchType.fromString(matchType), mapping);
|
||||
}
|
||||
|
||||
public XContentDynamicTemplate(Map<String, Object> conf, String match, String unmatch, String matchMappingType, MatchType matchType, Map<String, Object> mapping) {
|
||||
public DynamicTemplate(Map<String, Object> conf, String match, String unmatch, String matchMappingType, MatchType matchType, Map<String, Object> mapping) {
|
||||
this.conf = conf;
|
||||
this.match = match;
|
||||
this.unmatch = unmatch;
|
||||
|
@ -161,7 +161,7 @@ public class XContentDynamicTemplate {
|
|||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
|
||||
XContentDynamicTemplate that = (XContentDynamicTemplate) o;
|
||||
DynamicTemplate that = (DynamicTemplate) o;
|
||||
|
||||
// check if same matching, if so, replace the mapping
|
||||
if (match != null ? !match.equals(that.match) : that.match != null) return false;
|
|
@ -46,15 +46,15 @@ import static org.elasticsearch.index.mapper.xcontent.XContentTypeParsers.*;
|
|||
/**
|
||||
* @author kimchy (shay.banon)
|
||||
*/
|
||||
public class XContentFloatFieldMapper extends XContentNumberFieldMapper<Float> {
|
||||
public class FloatFieldMapper extends NumberFieldMapper<Float> {
|
||||
|
||||
public static final String CONTENT_TYPE = "float";
|
||||
|
||||
public static class Defaults extends XContentNumberFieldMapper.Defaults {
|
||||
public static class Defaults extends NumberFieldMapper.Defaults {
|
||||
public static final Float NULL_VALUE = null;
|
||||
}
|
||||
|
||||
public static class Builder extends XContentNumberFieldMapper.Builder<Builder, XContentFloatFieldMapper> {
|
||||
public static class Builder extends NumberFieldMapper.Builder<Builder, FloatFieldMapper> {
|
||||
|
||||
protected Float nullValue = Defaults.NULL_VALUE;
|
||||
|
||||
|
@ -68,17 +68,17 @@ public class XContentFloatFieldMapper extends XContentNumberFieldMapper<Float> {
|
|||
return this;
|
||||
}
|
||||
|
||||
@Override public XContentFloatFieldMapper build(BuilderContext context) {
|
||||
XContentFloatFieldMapper fieldMapper = new XContentFloatFieldMapper(buildNames(context),
|
||||
@Override public FloatFieldMapper build(BuilderContext context) {
|
||||
FloatFieldMapper fieldMapper = new FloatFieldMapper(buildNames(context),
|
||||
precisionStep, index, store, boost, omitNorms, omitTermFreqAndPositions, nullValue);
|
||||
fieldMapper.includeInAll(includeInAll);
|
||||
return fieldMapper;
|
||||
}
|
||||
}
|
||||
|
||||
public static class TypeParser implements XContentTypeParser {
|
||||
public static class TypeParser implements XContentMapper.TypeParser {
|
||||
@Override public XContentMapper.Builder parse(String name, Map<String, Object> node, ParserContext parserContext) throws MapperParsingException {
|
||||
XContentFloatFieldMapper.Builder builder = floatField(name);
|
||||
FloatFieldMapper.Builder builder = floatField(name);
|
||||
parseNumberField(builder, name, node, parserContext);
|
||||
for (Map.Entry<String, Object> entry : node.entrySet()) {
|
||||
String propName = Strings.toUnderscoreCase(entry.getKey());
|
||||
|
@ -95,9 +95,9 @@ public class XContentFloatFieldMapper extends XContentNumberFieldMapper<Float> {
|
|||
|
||||
private String nullValueAsString;
|
||||
|
||||
protected XContentFloatFieldMapper(Names names, int precisionStep, Field.Index index, Field.Store store,
|
||||
float boost, boolean omitNorms, boolean omitTermFreqAndPositions,
|
||||
Float nullValue) {
|
||||
protected FloatFieldMapper(Names names, int precisionStep, Field.Index index, Field.Store store,
|
||||
float boost, boolean omitNorms, boolean omitTermFreqAndPositions,
|
||||
Float nullValue) {
|
||||
super(names, precisionStep, index, store, boost, omitNorms, omitTermFreqAndPositions,
|
||||
new NamedAnalyzer("_float/" + precisionStep, new NumericFloatAnalyzer(precisionStep)),
|
||||
new NamedAnalyzer("_float/max", new NumericFloatAnalyzer(Integer.MAX_VALUE)));
|
||||
|
@ -197,8 +197,8 @@ public class XContentFloatFieldMapper extends XContentNumberFieldMapper<Float> {
|
|||
return;
|
||||
}
|
||||
if (!mergeContext.mergeFlags().simulate()) {
|
||||
this.nullValue = ((XContentFloatFieldMapper) mergeWith).nullValue;
|
||||
this.nullValueAsString = ((XContentFloatFieldMapper) mergeWith).nullValueAsString;
|
||||
this.nullValue = ((FloatFieldMapper) mergeWith).nullValue;
|
||||
this.nullValueAsString = ((FloatFieldMapper) mergeWith).nullValueAsString;
|
||||
}
|
||||
}
|
||||
|
|
@ -48,7 +48,7 @@ import static org.elasticsearch.index.mapper.xcontent.XContentTypeParsers.*;
|
|||
*
|
||||
* @author kimchy (shay.banon)
|
||||
*/
|
||||
public class XContentGeoPointFieldMapper implements XContentMapper, XContentArrayValueMapperParser {
|
||||
public class GeoPointFieldMapper implements XContentMapper, ArrayValueMapperParser {
|
||||
|
||||
public static final String CONTENT_TYPE = "geo_point";
|
||||
|
||||
|
@ -66,7 +66,7 @@ public class XContentGeoPointFieldMapper implements XContentMapper, XContentArra
|
|||
public static final Field.Store STORE = Field.Store.NO;
|
||||
}
|
||||
|
||||
public static class Builder extends XContentMapper.Builder<Builder, XContentGeoPointFieldMapper> {
|
||||
public static class Builder extends XContentMapper.Builder<Builder, GeoPointFieldMapper> {
|
||||
|
||||
private ContentPath.Type pathType = Defaults.PATH_TYPE;
|
||||
|
||||
|
@ -122,18 +122,18 @@ public class XContentGeoPointFieldMapper implements XContentMapper, XContentArra
|
|||
return this;
|
||||
}
|
||||
|
||||
@Override public XContentGeoPointFieldMapper build(BuilderContext context) {
|
||||
@Override public GeoPointFieldMapper build(BuilderContext context) {
|
||||
ContentPath.Type origPathType = context.path().pathType();
|
||||
context.path().pathType(pathType);
|
||||
|
||||
XContentNumberFieldMapper latMapper = null;
|
||||
XContentNumberFieldMapper lonMapper = null;
|
||||
XContentStringFieldMapper geohashMapper = null;
|
||||
NumberFieldMapper latMapper = null;
|
||||
NumberFieldMapper lonMapper = null;
|
||||
StringFieldMapper geohashMapper = null;
|
||||
|
||||
context.path().add(name);
|
||||
if (enableLatLon) {
|
||||
XContentNumberFieldMapper.Builder latMapperBuilder;
|
||||
XContentNumberFieldMapper.Builder lonMapperBuilder;
|
||||
NumberFieldMapper.Builder latMapperBuilder;
|
||||
NumberFieldMapper.Builder lonMapperBuilder;
|
||||
if ("32".equals(resolution)) {
|
||||
latMapperBuilder = floatField(Names.LAT).includeInAll(false);
|
||||
lonMapperBuilder = floatField(Names.LON).includeInAll(false);
|
||||
|
@ -147,8 +147,8 @@ public class XContentGeoPointFieldMapper implements XContentMapper, XContentArra
|
|||
latMapperBuilder.precisionStep(precisionStep);
|
||||
lonMapperBuilder.precisionStep(precisionStep);
|
||||
}
|
||||
latMapper = (XContentNumberFieldMapper) latMapperBuilder.includeInAll(false).store(store).build(context);
|
||||
lonMapper = (XContentNumberFieldMapper) lonMapperBuilder.includeInAll(false).store(store).build(context);
|
||||
latMapper = (NumberFieldMapper) latMapperBuilder.includeInAll(false).store(store).build(context);
|
||||
lonMapper = (NumberFieldMapper) lonMapperBuilder.includeInAll(false).store(store).build(context);
|
||||
}
|
||||
if (enableGeohash) {
|
||||
geohashMapper = stringField(Names.GEOHASH).includeInAll(false).build(context);
|
||||
|
@ -157,11 +157,11 @@ public class XContentGeoPointFieldMapper implements XContentMapper, XContentArra
|
|||
|
||||
context.path().pathType(origPathType);
|
||||
|
||||
return new XContentGeoPointFieldMapper(name, pathType, enableLatLon, enableGeohash, resolution, precisionStep, geohashPrecision, latMapper, lonMapper, geohashMapper);
|
||||
return new GeoPointFieldMapper(name, pathType, enableLatLon, enableGeohash, resolution, precisionStep, geohashPrecision, latMapper, lonMapper, geohashMapper);
|
||||
}
|
||||
}
|
||||
|
||||
public static class TypeParser implements XContentTypeParser {
|
||||
public static class TypeParser implements XContentMapper.TypeParser {
|
||||
@Override public XContentMapper.Builder parse(String name, Map<String, Object> node, ParserContext parserContext) throws MapperParsingException {
|
||||
Builder builder = new Builder(name);
|
||||
|
||||
|
@ -202,14 +202,14 @@ public class XContentGeoPointFieldMapper implements XContentMapper, XContentArra
|
|||
|
||||
private final int geohashPrecision;
|
||||
|
||||
private final XContentNumberFieldMapper latMapper;
|
||||
private final NumberFieldMapper latMapper;
|
||||
|
||||
private final XContentNumberFieldMapper lonMapper;
|
||||
private final NumberFieldMapper lonMapper;
|
||||
|
||||
private final XContentStringFieldMapper geohashMapper;
|
||||
private final StringFieldMapper geohashMapper;
|
||||
|
||||
public XContentGeoPointFieldMapper(String name, ContentPath.Type pathType, boolean enableLatLon, boolean enableGeohash, String resolution, Integer precisionStep, int geohashPrecision,
|
||||
XContentNumberFieldMapper latMapper, XContentNumberFieldMapper lonMapper, XContentStringFieldMapper geohashMapper) {
|
||||
public GeoPointFieldMapper(String name, ContentPath.Type pathType, boolean enableLatLon, boolean enableGeohash, String resolution, Integer precisionStep, int geohashPrecision,
|
||||
NumberFieldMapper latMapper, NumberFieldMapper lonMapper, StringFieldMapper geohashMapper) {
|
||||
this.name = name;
|
||||
this.pathType = pathType;
|
||||
this.enableLatLon = enableLatLon;
|
|
@ -24,7 +24,6 @@ import org.apache.lucene.document.Field;
|
|||
import org.apache.lucene.document.Fieldable;
|
||||
import org.elasticsearch.common.lucene.Lucene;
|
||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||
import org.elasticsearch.index.mapper.IdFieldMapper;
|
||||
import org.elasticsearch.index.mapper.MapperParsingException;
|
||||
import org.elasticsearch.index.mapper.MergeMappingException;
|
||||
|
||||
|
@ -33,11 +32,11 @@ import java.io.IOException;
|
|||
/**
|
||||
* @author kimchy (shay.banon)
|
||||
*/
|
||||
public class XContentIdFieldMapper extends XContentFieldMapper<String> implements IdFieldMapper {
|
||||
public class IdFieldMapper extends AbstractFieldMapper<String> implements org.elasticsearch.index.mapper.IdFieldMapper {
|
||||
|
||||
public static final String CONTENT_TYPE = "_id";
|
||||
|
||||
public static class Defaults extends XContentFieldMapper.Defaults {
|
||||
public static class Defaults extends AbstractFieldMapper.Defaults {
|
||||
public static final String NAME = "_id";
|
||||
public static final String INDEX_NAME = "_id";
|
||||
public static final Field.Index INDEX = Field.Index.NOT_ANALYZED;
|
||||
|
@ -46,7 +45,7 @@ public class XContentIdFieldMapper extends XContentFieldMapper<String> implement
|
|||
public static final boolean OMIT_TERM_FREQ_AND_POSITIONS = true;
|
||||
}
|
||||
|
||||
public static class Builder extends XContentFieldMapper.Builder<Builder, XContentIdFieldMapper> {
|
||||
public static class Builder extends AbstractFieldMapper.Builder<Builder, IdFieldMapper> {
|
||||
|
||||
public Builder() {
|
||||
super(Defaults.NAME);
|
||||
|
@ -57,22 +56,22 @@ public class XContentIdFieldMapper extends XContentFieldMapper<String> implement
|
|||
omitTermFreqAndPositions = Defaults.OMIT_TERM_FREQ_AND_POSITIONS;
|
||||
}
|
||||
|
||||
@Override public XContentIdFieldMapper build(BuilderContext context) {
|
||||
return new XContentIdFieldMapper(name, indexName, store, termVector, boost, omitNorms, omitTermFreqAndPositions);
|
||||
@Override public IdFieldMapper build(BuilderContext context) {
|
||||
return new IdFieldMapper(name, indexName, store, termVector, boost, omitNorms, omitTermFreqAndPositions);
|
||||
}
|
||||
}
|
||||
|
||||
protected XContentIdFieldMapper() {
|
||||
protected IdFieldMapper() {
|
||||
this(Defaults.NAME, Defaults.INDEX_NAME);
|
||||
}
|
||||
|
||||
protected XContentIdFieldMapper(String name, String indexName) {
|
||||
protected IdFieldMapper(String name, String indexName) {
|
||||
this(name, indexName, Defaults.STORE, Defaults.TERM_VECTOR, Defaults.BOOST,
|
||||
Defaults.OMIT_NORMS, Defaults.OMIT_TERM_FREQ_AND_POSITIONS);
|
||||
}
|
||||
|
||||
protected XContentIdFieldMapper(String name, String indexName, Field.Store store, Field.TermVector termVector,
|
||||
float boost, boolean omitNorms, boolean omitTermFreqAndPositions) {
|
||||
protected IdFieldMapper(String name, String indexName, Field.Store store, Field.TermVector termVector,
|
||||
float boost, boolean omitNorms, boolean omitTermFreqAndPositions) {
|
||||
super(new Names(name, indexName, indexName, name), Defaults.INDEX, store, termVector, boost, omitNorms, omitTermFreqAndPositions,
|
||||
Lucene.KEYWORD_ANALYZER, Lucene.KEYWORD_ANALYZER);
|
||||
}
|
|
@ -22,7 +22,7 @@ package org.elasticsearch.index.mapper.xcontent;
|
|||
/**
|
||||
* @author kimchy (shay.banon)
|
||||
*/
|
||||
public interface XContentIncludeInAllMapper extends XContentMapper {
|
||||
public interface IncludeInAllMapper extends XContentMapper {
|
||||
|
||||
void includeInAll(Boolean includeInAll);
|
||||
}
|
|
@ -25,7 +25,6 @@ import org.apache.lucene.document.Fieldable;
|
|||
import org.apache.lucene.index.Term;
|
||||
import org.elasticsearch.common.lucene.Lucene;
|
||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||
import org.elasticsearch.index.mapper.IndexFieldMapper;
|
||||
import org.elasticsearch.index.mapper.MergeMappingException;
|
||||
|
||||
import java.io.IOException;
|
||||
|
@ -33,13 +32,13 @@ import java.io.IOException;
|
|||
/**
|
||||
* @author kimchy (shay.banon)
|
||||
*/
|
||||
public class XContentIndexFieldMapper extends XContentFieldMapper<String> implements IndexFieldMapper {
|
||||
public class IndexFieldMapper extends AbstractFieldMapper<String> implements org.elasticsearch.index.mapper.IndexFieldMapper {
|
||||
|
||||
public static final String CONTENT_TYPE = "_index";
|
||||
|
||||
public static class Defaults extends XContentFieldMapper.Defaults {
|
||||
public static final String NAME = IndexFieldMapper.NAME;
|
||||
public static final String INDEX_NAME = IndexFieldMapper.NAME;
|
||||
public static class Defaults extends AbstractFieldMapper.Defaults {
|
||||
public static final String NAME = org.elasticsearch.index.mapper.IndexFieldMapper.NAME;
|
||||
public static final String INDEX_NAME = org.elasticsearch.index.mapper.IndexFieldMapper.NAME;
|
||||
public static final Field.Index INDEX = Field.Index.NOT_ANALYZED;
|
||||
public static final Field.Store STORE = Field.Store.NO;
|
||||
public static final boolean OMIT_NORMS = true;
|
||||
|
@ -47,7 +46,7 @@ public class XContentIndexFieldMapper extends XContentFieldMapper<String> implem
|
|||
public static final boolean ENABLED = false;
|
||||
}
|
||||
|
||||
public static class Builder extends XContentFieldMapper.Builder<Builder, XContentIndexFieldMapper> {
|
||||
public static class Builder extends AbstractFieldMapper.Builder<Builder, IndexFieldMapper> {
|
||||
|
||||
private boolean enabled = Defaults.ENABLED;
|
||||
|
||||
|
@ -65,24 +64,24 @@ public class XContentIndexFieldMapper extends XContentFieldMapper<String> implem
|
|||
return this;
|
||||
}
|
||||
|
||||
@Override public XContentIndexFieldMapper build(BuilderContext context) {
|
||||
return new XContentIndexFieldMapper(name, indexName, store, termVector, boost, omitNorms, omitTermFreqAndPositions, enabled);
|
||||
@Override public IndexFieldMapper build(BuilderContext context) {
|
||||
return new IndexFieldMapper(name, indexName, store, termVector, boost, omitNorms, omitTermFreqAndPositions, enabled);
|
||||
}
|
||||
}
|
||||
|
||||
private final boolean enabled;
|
||||
|
||||
protected XContentIndexFieldMapper() {
|
||||
protected IndexFieldMapper() {
|
||||
this(Defaults.NAME, Defaults.INDEX_NAME);
|
||||
}
|
||||
|
||||
protected XContentIndexFieldMapper(String name, String indexName) {
|
||||
protected IndexFieldMapper(String name, String indexName) {
|
||||
this(name, indexName, Defaults.STORE, Defaults.TERM_VECTOR, Defaults.BOOST,
|
||||
Defaults.OMIT_NORMS, Defaults.OMIT_TERM_FREQ_AND_POSITIONS, Defaults.ENABLED);
|
||||
}
|
||||
|
||||
public XContentIndexFieldMapper(String name, String indexName, Field.Store store, Field.TermVector termVector,
|
||||
float boost, boolean omitNorms, boolean omitTermFreqAndPositions, boolean enabled) {
|
||||
public IndexFieldMapper(String name, String indexName, Field.Store store, Field.TermVector termVector,
|
||||
float boost, boolean omitNorms, boolean omitTermFreqAndPositions, boolean enabled) {
|
||||
super(new Names(name, indexName, indexName, name), Defaults.INDEX, store, termVector, boost, omitNorms, omitTermFreqAndPositions,
|
||||
Lucene.KEYWORD_ANALYZER, Lucene.KEYWORD_ANALYZER);
|
||||
this.enabled = enabled;
|
|
@ -46,15 +46,15 @@ import static org.elasticsearch.index.mapper.xcontent.XContentTypeParsers.*;
|
|||
/**
|
||||
* @author kimchy (shay.banon)
|
||||
*/
|
||||
public class XContentIntegerFieldMapper extends XContentNumberFieldMapper<Integer> {
|
||||
public class IntegerFieldMapper extends NumberFieldMapper<Integer> {
|
||||
|
||||
public static final String CONTENT_TYPE = "integer";
|
||||
|
||||
public static class Defaults extends XContentNumberFieldMapper.Defaults {
|
||||
public static class Defaults extends NumberFieldMapper.Defaults {
|
||||
public static final Integer NULL_VALUE = null;
|
||||
}
|
||||
|
||||
public static class Builder extends XContentNumberFieldMapper.Builder<Builder, XContentIntegerFieldMapper> {
|
||||
public static class Builder extends NumberFieldMapper.Builder<Builder, IntegerFieldMapper> {
|
||||
|
||||
protected Integer nullValue = Defaults.NULL_VALUE;
|
||||
|
||||
|
@ -68,17 +68,17 @@ public class XContentIntegerFieldMapper extends XContentNumberFieldMapper<Intege
|
|||
return this;
|
||||
}
|
||||
|
||||
@Override public XContentIntegerFieldMapper build(BuilderContext context) {
|
||||
XContentIntegerFieldMapper fieldMapper = new XContentIntegerFieldMapper(buildNames(context),
|
||||
@Override public IntegerFieldMapper build(BuilderContext context) {
|
||||
IntegerFieldMapper fieldMapper = new IntegerFieldMapper(buildNames(context),
|
||||
precisionStep, index, store, boost, omitNorms, omitTermFreqAndPositions, nullValue);
|
||||
fieldMapper.includeInAll(includeInAll);
|
||||
return fieldMapper;
|
||||
}
|
||||
}
|
||||
|
||||
public static class TypeParser implements XContentTypeParser {
|
||||
public static class TypeParser implements XContentMapper.TypeParser {
|
||||
@Override public XContentMapper.Builder parse(String name, Map<String, Object> node, ParserContext parserContext) throws MapperParsingException {
|
||||
XContentIntegerFieldMapper.Builder builder = integerField(name);
|
||||
IntegerFieldMapper.Builder builder = integerField(name);
|
||||
parseNumberField(builder, name, node, parserContext);
|
||||
for (Map.Entry<String, Object> entry : node.entrySet()) {
|
||||
String propName = Strings.toUnderscoreCase(entry.getKey());
|
||||
|
@ -95,9 +95,9 @@ public class XContentIntegerFieldMapper extends XContentNumberFieldMapper<Intege
|
|||
|
||||
private String nullValueAsString;
|
||||
|
||||
protected XContentIntegerFieldMapper(Names names, int precisionStep, Field.Index index, Field.Store store,
|
||||
float boost, boolean omitNorms, boolean omitTermFreqAndPositions,
|
||||
Integer nullValue) {
|
||||
protected IntegerFieldMapper(Names names, int precisionStep, Field.Index index, Field.Store store,
|
||||
float boost, boolean omitNorms, boolean omitTermFreqAndPositions,
|
||||
Integer nullValue) {
|
||||
super(names, precisionStep, index, store, boost, omitNorms, omitTermFreqAndPositions,
|
||||
new NamedAnalyzer("_int/" + precisionStep, new NumericIntegerAnalyzer(precisionStep)),
|
||||
new NamedAnalyzer("_int/max", new NumericIntegerAnalyzer(Integer.MAX_VALUE)));
|
||||
|
@ -197,8 +197,8 @@ public class XContentIntegerFieldMapper extends XContentNumberFieldMapper<Intege
|
|||
return;
|
||||
}
|
||||
if (!mergeContext.mergeFlags().simulate()) {
|
||||
this.nullValue = ((XContentIntegerFieldMapper) mergeWith).nullValue;
|
||||
this.nullValueAsString = ((XContentIntegerFieldMapper) mergeWith).nullValueAsString;
|
||||
this.nullValue = ((IntegerFieldMapper) mergeWith).nullValue;
|
||||
this.nullValueAsString = ((IntegerFieldMapper) mergeWith).nullValueAsString;
|
||||
}
|
||||
}
|
||||
|
|
@ -46,15 +46,15 @@ import static org.elasticsearch.index.mapper.xcontent.XContentTypeParsers.*;
|
|||
/**
|
||||
* @author kimchy (shay.banon)
|
||||
*/
|
||||
public class XContentLongFieldMapper extends XContentNumberFieldMapper<Long> {
|
||||
public class LongFieldMapper extends NumberFieldMapper<Long> {
|
||||
|
||||
public static final String CONTENT_TYPE = "long";
|
||||
|
||||
public static class Defaults extends XContentNumberFieldMapper.Defaults {
|
||||
public static class Defaults extends NumberFieldMapper.Defaults {
|
||||
public static final Long NULL_VALUE = null;
|
||||
}
|
||||
|
||||
public static class Builder extends XContentNumberFieldMapper.Builder<Builder, XContentLongFieldMapper> {
|
||||
public static class Builder extends NumberFieldMapper.Builder<Builder, LongFieldMapper> {
|
||||
|
||||
protected Long nullValue = Defaults.NULL_VALUE;
|
||||
|
||||
|
@ -68,17 +68,17 @@ public class XContentLongFieldMapper extends XContentNumberFieldMapper<Long> {
|
|||
return this;
|
||||
}
|
||||
|
||||
@Override public XContentLongFieldMapper build(BuilderContext context) {
|
||||
XContentLongFieldMapper fieldMapper = new XContentLongFieldMapper(buildNames(context),
|
||||
@Override public LongFieldMapper build(BuilderContext context) {
|
||||
LongFieldMapper fieldMapper = new LongFieldMapper(buildNames(context),
|
||||
precisionStep, index, store, boost, omitNorms, omitTermFreqAndPositions, nullValue);
|
||||
fieldMapper.includeInAll(includeInAll);
|
||||
return fieldMapper;
|
||||
}
|
||||
}
|
||||
|
||||
public static class TypeParser implements XContentTypeParser {
|
||||
public static class TypeParser implements XContentMapper.TypeParser {
|
||||
@Override public XContentMapper.Builder parse(String name, Map<String, Object> node, ParserContext parserContext) throws MapperParsingException {
|
||||
XContentLongFieldMapper.Builder builder = longField(name);
|
||||
LongFieldMapper.Builder builder = longField(name);
|
||||
parseNumberField(builder, name, node, parserContext);
|
||||
for (Map.Entry<String, Object> entry : node.entrySet()) {
|
||||
String propName = Strings.toUnderscoreCase(entry.getKey());
|
||||
|
@ -95,9 +95,9 @@ public class XContentLongFieldMapper extends XContentNumberFieldMapper<Long> {
|
|||
|
||||
private String nullValueAsString;
|
||||
|
||||
protected XContentLongFieldMapper(Names names, int precisionStep, Field.Index index, Field.Store store,
|
||||
float boost, boolean omitNorms, boolean omitTermFreqAndPositions,
|
||||
Long nullValue) {
|
||||
protected LongFieldMapper(Names names, int precisionStep, Field.Index index, Field.Store store,
|
||||
float boost, boolean omitNorms, boolean omitTermFreqAndPositions,
|
||||
Long nullValue) {
|
||||
super(names, precisionStep, index, store, boost, omitNorms, omitTermFreqAndPositions,
|
||||
new NamedAnalyzer("_long/" + precisionStep, new NumericLongAnalyzer(precisionStep)),
|
||||
new NamedAnalyzer("_long/max", new NumericLongAnalyzer(Integer.MAX_VALUE)));
|
||||
|
@ -197,8 +197,8 @@ public class XContentLongFieldMapper extends XContentNumberFieldMapper<Long> {
|
|||
return;
|
||||
}
|
||||
if (!mergeContext.mergeFlags().simulate()) {
|
||||
this.nullValue = ((XContentLongFieldMapper) mergeWith).nullValue;
|
||||
this.nullValueAsString = ((XContentLongFieldMapper) mergeWith).nullValueAsString;
|
||||
this.nullValue = ((LongFieldMapper) mergeWith).nullValue;
|
||||
this.nullValueAsString = ((LongFieldMapper) mergeWith).nullValueAsString;
|
||||
}
|
||||
}
|
||||
|
|
@ -40,7 +40,7 @@ import static org.elasticsearch.index.mapper.xcontent.XContentTypeParsers.*;
|
|||
/**
|
||||
* @author kimchy (shay.banon)
|
||||
*/
|
||||
public class XContentMultiFieldMapper implements XContentMapper, XContentIncludeInAllMapper {
|
||||
public class MultiFieldMapper implements XContentMapper, IncludeInAllMapper {
|
||||
|
||||
public static final String CONTENT_TYPE = "multi_field";
|
||||
|
||||
|
@ -48,7 +48,7 @@ public class XContentMultiFieldMapper implements XContentMapper, XContentInclude
|
|||
public static final ContentPath.Type PATH_TYPE = ContentPath.Type.FULL;
|
||||
}
|
||||
|
||||
public static class Builder extends XContentMapper.Builder<Builder, XContentMultiFieldMapper> {
|
||||
public static class Builder extends XContentMapper.Builder<Builder, MultiFieldMapper> {
|
||||
|
||||
private ContentPath.Type pathType = Defaults.PATH_TYPE;
|
||||
|
||||
|
@ -75,7 +75,7 @@ public class XContentMultiFieldMapper implements XContentMapper, XContentInclude
|
|||
return this;
|
||||
}
|
||||
|
||||
@Override public XContentMultiFieldMapper build(BuilderContext context) {
|
||||
@Override public MultiFieldMapper build(BuilderContext context) {
|
||||
ContentPath.Type origPathType = context.path().pathType();
|
||||
context.path().pathType(pathType);
|
||||
|
||||
|
@ -94,13 +94,13 @@ public class XContentMultiFieldMapper implements XContentMapper, XContentInclude
|
|||
|
||||
context.path().pathType(origPathType);
|
||||
|
||||
return new XContentMultiFieldMapper(name, pathType, mappers, defaultMapper);
|
||||
return new MultiFieldMapper(name, pathType, mappers, defaultMapper);
|
||||
}
|
||||
}
|
||||
|
||||
public static class TypeParser implements XContentTypeParser {
|
||||
public static class TypeParser implements XContentMapper.TypeParser {
|
||||
@Override public XContentMapper.Builder parse(String name, Map<String, Object> node, ParserContext parserContext) throws MapperParsingException {
|
||||
XContentMultiFieldMapper.Builder builder = multiField(name);
|
||||
MultiFieldMapper.Builder builder = multiField(name);
|
||||
|
||||
for (Map.Entry<String, Object> entry : node.entrySet()) {
|
||||
String fieldName = Strings.toUnderscoreCase(entry.getKey());
|
||||
|
@ -121,7 +121,7 @@ public class XContentMultiFieldMapper implements XContentMapper, XContentInclude
|
|||
throw new MapperParsingException("No type specified for property [" + propName + "]");
|
||||
}
|
||||
|
||||
XContentTypeParser typeParser = parserContext.typeParser(type);
|
||||
XContentMapper.TypeParser typeParser = parserContext.typeParser(type);
|
||||
if (typeParser == null) {
|
||||
throw new MapperParsingException("No handler for type [" + type + "] declared on field [" + fieldName + "]");
|
||||
}
|
||||
|
@ -143,11 +143,11 @@ public class XContentMultiFieldMapper implements XContentMapper, XContentInclude
|
|||
|
||||
private volatile XContentMapper defaultMapper;
|
||||
|
||||
public XContentMultiFieldMapper(String name, ContentPath.Type pathType, XContentMapper defaultMapper) {
|
||||
public MultiFieldMapper(String name, ContentPath.Type pathType, XContentMapper defaultMapper) {
|
||||
this(name, pathType, new HashMap<String, XContentMapper>(), defaultMapper);
|
||||
}
|
||||
|
||||
public XContentMultiFieldMapper(String name, ContentPath.Type pathType, Map<String, XContentMapper> mappers, XContentMapper defaultMapper) {
|
||||
public MultiFieldMapper(String name, ContentPath.Type pathType, Map<String, XContentMapper> mappers, XContentMapper defaultMapper) {
|
||||
this.name = name;
|
||||
this.pathType = pathType;
|
||||
this.mappers = ImmutableMap.copyOf(mappers);
|
||||
|
@ -155,8 +155,8 @@ public class XContentMultiFieldMapper implements XContentMapper, XContentInclude
|
|||
|
||||
// we disable the all in mappers, only the default one can be added
|
||||
for (XContentMapper mapper : mappers.values()) {
|
||||
if (mapper instanceof XContentIncludeInAllMapper) {
|
||||
((XContentIncludeInAllMapper) mapper).includeInAll(false);
|
||||
if (mapper instanceof IncludeInAllMapper) {
|
||||
((IncludeInAllMapper) mapper).includeInAll(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -166,8 +166,8 @@ public class XContentMultiFieldMapper implements XContentMapper, XContentInclude
|
|||
}
|
||||
|
||||
@Override public void includeInAll(Boolean includeInAll) {
|
||||
if (includeInAll != null && defaultMapper != null && (defaultMapper instanceof XContentIncludeInAllMapper)) {
|
||||
((XContentIncludeInAllMapper) defaultMapper).includeInAll(includeInAll);
|
||||
if (includeInAll != null && defaultMapper != null && (defaultMapper instanceof IncludeInAllMapper)) {
|
||||
((IncludeInAllMapper) defaultMapper).includeInAll(includeInAll);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -202,12 +202,12 @@ public class XContentMultiFieldMapper implements XContentMapper, XContentInclude
|
|||
}
|
||||
|
||||
@Override public void merge(XContentMapper mergeWith, MergeContext mergeContext) throws MergeMappingException {
|
||||
if (!(mergeWith instanceof XContentMultiFieldMapper) && !(mergeWith instanceof XContentFieldMapper)) {
|
||||
if (!(mergeWith instanceof MultiFieldMapper) && !(mergeWith instanceof AbstractFieldMapper)) {
|
||||
mergeContext.addConflict("Can't merge a non multi_field / non simple mapping [" + mergeWith.name() + "] with a multi_field mapping [" + name() + "]");
|
||||
return;
|
||||
}
|
||||
synchronized (mutex) {
|
||||
if (mergeWith instanceof XContentFieldMapper) {
|
||||
if (mergeWith instanceof AbstractFieldMapper) {
|
||||
// its a single field mapper, upgraded into a multi field mapper, just update the default mapper
|
||||
if (defaultMapper == null) {
|
||||
if (!mergeContext.mergeFlags().simulate()) {
|
||||
|
@ -216,7 +216,7 @@ public class XContentMultiFieldMapper implements XContentMapper, XContentInclude
|
|||
}
|
||||
}
|
||||
} else {
|
||||
XContentMultiFieldMapper mergeWithMultiField = (XContentMultiFieldMapper) mergeWith;
|
||||
MultiFieldMapper mergeWithMultiField = (MultiFieldMapper) mergeWith;
|
||||
// merge the default mapper
|
||||
if (defaultMapper == null) {
|
||||
if (mergeWithMultiField.defaultMapper != null) {
|
||||
|
@ -238,11 +238,11 @@ public class XContentMultiFieldMapper implements XContentMapper, XContentInclude
|
|||
// no mapping, simply add it if not simulating
|
||||
if (!mergeContext.mergeFlags().simulate()) {
|
||||
// disable the mapper from being in all, only the default mapper is in all
|
||||
if (mergeWithMapper instanceof XContentIncludeInAllMapper) {
|
||||
((XContentIncludeInAllMapper) mergeWithMapper).includeInAll(false);
|
||||
if (mergeWithMapper instanceof IncludeInAllMapper) {
|
||||
((IncludeInAllMapper) mergeWithMapper).includeInAll(false);
|
||||
}
|
||||
mappers = newMapBuilder(mappers).put(mergeWithMapper.name(), mergeWithMapper).immutableMap();
|
||||
if (mergeWithMapper instanceof XContentFieldMapper) {
|
||||
if (mergeWithMapper instanceof AbstractFieldMapper) {
|
||||
mergeContext.docMapper().addFieldMapper((FieldMapper) mergeWithMapper);
|
||||
}
|
||||
}
|
|
@ -40,16 +40,16 @@ import java.util.Deque;
|
|||
/**
|
||||
* @author kimchy (shay.banon)
|
||||
*/
|
||||
public abstract class XContentNumberFieldMapper<T extends Number> extends XContentFieldMapper<T> implements XContentIncludeInAllMapper {
|
||||
public abstract class NumberFieldMapper<T extends Number> extends AbstractFieldMapper<T> implements IncludeInAllMapper {
|
||||
|
||||
public static class Defaults extends XContentFieldMapper.Defaults {
|
||||
public static class Defaults extends AbstractFieldMapper.Defaults {
|
||||
public static final int PRECISION_STEP = NumericUtils.PRECISION_STEP_DEFAULT;
|
||||
public static final Field.Index INDEX = Field.Index.NOT_ANALYZED;
|
||||
public static final boolean OMIT_NORMS = true;
|
||||
public static final boolean OMIT_TERM_FREQ_AND_POSITIONS = true;
|
||||
}
|
||||
|
||||
public abstract static class Builder<T extends Builder, Y extends XContentNumberFieldMapper> extends XContentFieldMapper.Builder<T, Y> {
|
||||
public abstract static class Builder<T extends Builder, Y extends NumberFieldMapper> extends AbstractFieldMapper.Builder<T, Y> {
|
||||
|
||||
protected int precisionStep = Defaults.PRECISION_STEP;
|
||||
|
||||
|
@ -92,10 +92,10 @@ public abstract class XContentNumberFieldMapper<T extends Number> extends XConte
|
|||
|
||||
protected Boolean includeInAll;
|
||||
|
||||
protected XContentNumberFieldMapper(Names names, int precisionStep,
|
||||
Field.Index index, Field.Store store,
|
||||
float boost, boolean omitNorms, boolean omitTermFreqAndPositions,
|
||||
NamedAnalyzer indexAnalyzer, NamedAnalyzer searchAnalyzer) {
|
||||
protected NumberFieldMapper(Names names, int precisionStep,
|
||||
Field.Index index, Field.Store store,
|
||||
float boost, boolean omitNorms, boolean omitTermFreqAndPositions,
|
||||
NamedAnalyzer indexAnalyzer, NamedAnalyzer searchAnalyzer) {
|
||||
super(names, index, store, Field.TermVector.NO, boost, omitNorms, omitTermFreqAndPositions, indexAnalyzer, searchAnalyzer);
|
||||
if (precisionStep <= 0 || precisionStep >= maxPrecisionStep()) {
|
||||
this.precisionStep = Integer.MAX_VALUE;
|
||||
|
@ -161,8 +161,8 @@ public abstract class XContentNumberFieldMapper<T extends Number> extends XConte
|
|||
return;
|
||||
}
|
||||
if (!mergeContext.mergeFlags().simulate()) {
|
||||
this.precisionStep = ((XContentNumberFieldMapper) mergeWith).precisionStep;
|
||||
this.includeInAll = ((XContentNumberFieldMapper) mergeWith).includeInAll;
|
||||
this.precisionStep = ((NumberFieldMapper) mergeWith).precisionStep;
|
||||
this.includeInAll = ((NumberFieldMapper) mergeWith).includeInAll;
|
||||
}
|
||||
}
|
||||
|
|
@ -47,7 +47,7 @@ import static org.elasticsearch.index.mapper.xcontent.XContentTypeParsers.*;
|
|||
* @author kimchy (shay.banon)
|
||||
*/
|
||||
@ThreadSafe
|
||||
public class XContentObjectMapper implements XContentMapper, XContentIncludeInAllMapper {
|
||||
public class ObjectMapper implements XContentMapper, IncludeInAllMapper {
|
||||
|
||||
public static final String CONTENT_TYPE = "object";
|
||||
|
||||
|
@ -57,12 +57,12 @@ public class XContentObjectMapper implements XContentMapper, XContentIncludeInAl
|
|||
public static final ContentPath.Type PATH_TYPE = ContentPath.Type.FULL;
|
||||
public static final FormatDateTimeFormatter[] DATE_TIME_FORMATTERS =
|
||||
new FormatDateTimeFormatter[]{
|
||||
XContentDateFieldMapper.Defaults.DATE_TIME_FORMATTER,
|
||||
DateFieldMapper.Defaults.DATE_TIME_FORMATTER,
|
||||
Joda.forPattern("yyyy/MM/dd HH:mm:ss||yyyy/MM/dd")
|
||||
};
|
||||
}
|
||||
|
||||
public static class Builder extends XContentMapper.Builder<Builder, XContentObjectMapper> {
|
||||
public static class Builder extends XContentMapper.Builder<Builder, ObjectMapper> {
|
||||
|
||||
private boolean enabled = Defaults.ENABLED;
|
||||
|
||||
|
@ -76,7 +76,7 @@ public class XContentObjectMapper implements XContentMapper, XContentIncludeInAl
|
|||
|
||||
private final List<XContentMapper.Builder> mappersBuilders = newArrayList();
|
||||
|
||||
private final List<XContentDynamicTemplate> dynamicTemplates = newArrayList();
|
||||
private final List<DynamicTemplate> dynamicTemplates = newArrayList();
|
||||
|
||||
public Builder(String name) {
|
||||
super(name);
|
||||
|
@ -125,13 +125,13 @@ public class XContentObjectMapper implements XContentMapper, XContentIncludeInAl
|
|||
return this;
|
||||
}
|
||||
|
||||
public Builder add(XContentDynamicTemplate dynamicTemplate) {
|
||||
public Builder add(DynamicTemplate dynamicTemplate) {
|
||||
this.dynamicTemplates.add(dynamicTemplate);
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder add(XContentDynamicTemplate... dynamicTemplate) {
|
||||
for (XContentDynamicTemplate template : dynamicTemplate) {
|
||||
public Builder add(DynamicTemplate... dynamicTemplate) {
|
||||
for (DynamicTemplate template : dynamicTemplate) {
|
||||
this.dynamicTemplates.add(template);
|
||||
}
|
||||
return this;
|
||||
|
@ -142,7 +142,7 @@ public class XContentObjectMapper implements XContentMapper, XContentIncludeInAl
|
|||
return this;
|
||||
}
|
||||
|
||||
@Override public XContentObjectMapper build(BuilderContext context) {
|
||||
@Override public ObjectMapper build(BuilderContext context) {
|
||||
if (dateTimeFormatters == null) {
|
||||
dateTimeFormatters = newArrayList();
|
||||
} else if (dateTimeFormatters.isEmpty()) {
|
||||
|
@ -158,9 +158,9 @@ public class XContentObjectMapper implements XContentMapper, XContentIncludeInAl
|
|||
XContentMapper mapper = builder.build(context);
|
||||
mappers.put(mapper.name(), mapper);
|
||||
}
|
||||
XContentObjectMapper objectMapper = new XContentObjectMapper(name, enabled, dynamic, pathType,
|
||||
ObjectMapper objectMapper = new ObjectMapper(name, enabled, dynamic, pathType,
|
||||
dateTimeFormatters.toArray(new FormatDateTimeFormatter[dateTimeFormatters.size()]),
|
||||
mappers, dynamicTemplates.toArray(new XContentDynamicTemplate[dynamicTemplates.size()]));
|
||||
mappers, dynamicTemplates.toArray(new DynamicTemplate[dynamicTemplates.size()]));
|
||||
|
||||
context.path().pathType(origPathType);
|
||||
context.path().remove();
|
||||
|
@ -171,10 +171,10 @@ public class XContentObjectMapper implements XContentMapper, XContentIncludeInAl
|
|||
}
|
||||
}
|
||||
|
||||
public static class TypeParser implements XContentTypeParser {
|
||||
public static class TypeParser implements XContentMapper.TypeParser {
|
||||
@Override public XContentMapper.Builder parse(String name, Map<String, Object> node, ParserContext parserContext) throws MapperParsingException {
|
||||
Map<String, Object> objectNode = node;
|
||||
XContentObjectMapper.Builder builder = object(name);
|
||||
ObjectMapper.Builder builder = object(name);
|
||||
|
||||
for (Map.Entry<String, Object> entry : objectNode.entrySet()) {
|
||||
String fieldName = Strings.toUnderscoreCase(entry.getKey());
|
||||
|
@ -198,7 +198,7 @@ public class XContentObjectMapper implements XContentMapper, XContentIncludeInAl
|
|||
List tmplNodes = (List) fieldNode;
|
||||
for (Object tmplNode : tmplNodes) {
|
||||
Map<String, Object> tmpl = (Map<String, Object>) tmplNode;
|
||||
builder.add(XContentDynamicTemplate.parse(tmpl));
|
||||
builder.add(DynamicTemplate.parse(tmpl));
|
||||
}
|
||||
} else if (fieldName.equals("date_formats")) {
|
||||
List<FormatDateTimeFormatter> dateTimeFormatters = newArrayList();
|
||||
|
@ -229,7 +229,7 @@ public class XContentObjectMapper implements XContentMapper, XContentIncludeInAl
|
|||
return builder;
|
||||
}
|
||||
|
||||
private void parseProperties(XContentObjectMapper.Builder objBuilder, Map<String, Object> propsNode, XContentTypeParser.ParserContext parserContext) {
|
||||
private void parseProperties(ObjectMapper.Builder objBuilder, Map<String, Object> propsNode, ParserContext parserContext) {
|
||||
for (Map.Entry<String, Object> entry : propsNode.entrySet()) {
|
||||
String propName = entry.getKey();
|
||||
Map<String, Object> propNode = (Map<String, Object>) entry.getValue();
|
||||
|
@ -241,15 +241,15 @@ public class XContentObjectMapper implements XContentMapper, XContentIncludeInAl
|
|||
} else {
|
||||
// lets see if we can derive this...
|
||||
if (propNode.get("properties") != null) {
|
||||
type = XContentObjectMapper.CONTENT_TYPE;
|
||||
type = ObjectMapper.CONTENT_TYPE;
|
||||
} else if (propNode.get("fields") != null) {
|
||||
type = XContentMultiFieldMapper.CONTENT_TYPE;
|
||||
type = MultiFieldMapper.CONTENT_TYPE;
|
||||
} else {
|
||||
throw new MapperParsingException("No type specified for property [" + propName + "]");
|
||||
}
|
||||
}
|
||||
|
||||
XContentTypeParser typeParser = parserContext.typeParser(type);
|
||||
XContentMapper.TypeParser typeParser = parserContext.typeParser(type);
|
||||
if (typeParser == null) {
|
||||
throw new MapperParsingException("No handler for type [" + type + "] declared on field [" + propName + "]");
|
||||
}
|
||||
|
@ -272,31 +272,31 @@ public class XContentObjectMapper implements XContentMapper, XContentIncludeInAl
|
|||
|
||||
private volatile ImmutableMap<String, XContentMapper> mappers = ImmutableMap.of();
|
||||
|
||||
private volatile XContentDynamicTemplate dynamicTemplates[];
|
||||
private volatile DynamicTemplate dynamicTemplates[];
|
||||
|
||||
private final Object mutex = new Object();
|
||||
|
||||
protected XContentObjectMapper(String name) {
|
||||
protected ObjectMapper(String name) {
|
||||
this(name, Defaults.ENABLED, Defaults.DYNAMIC, Defaults.PATH_TYPE);
|
||||
}
|
||||
|
||||
protected XContentObjectMapper(String name, boolean enabled, boolean dynamic, ContentPath.Type pathType) {
|
||||
protected ObjectMapper(String name, boolean enabled, boolean dynamic, ContentPath.Type pathType) {
|
||||
this(name, enabled, dynamic, pathType, Defaults.DATE_TIME_FORMATTERS);
|
||||
}
|
||||
|
||||
protected XContentObjectMapper(String name, boolean enabled, boolean dynamic, ContentPath.Type pathType,
|
||||
FormatDateTimeFormatter[] dateTimeFormatters) {
|
||||
protected ObjectMapper(String name, boolean enabled, boolean dynamic, ContentPath.Type pathType,
|
||||
FormatDateTimeFormatter[] dateTimeFormatters) {
|
||||
this(name, enabled, dynamic, pathType, dateTimeFormatters, null, null);
|
||||
}
|
||||
|
||||
XContentObjectMapper(String name, boolean enabled, boolean dynamic, ContentPath.Type pathType,
|
||||
FormatDateTimeFormatter[] dateTimeFormatters, Map<String, XContentMapper> mappers, XContentDynamicTemplate dynamicTemplates[]) {
|
||||
ObjectMapper(String name, boolean enabled, boolean dynamic, ContentPath.Type pathType,
|
||||
FormatDateTimeFormatter[] dateTimeFormatters, Map<String, XContentMapper> mappers, DynamicTemplate dynamicTemplates[]) {
|
||||
this.name = name;
|
||||
this.enabled = enabled;
|
||||
this.dynamic = dynamic;
|
||||
this.pathType = pathType;
|
||||
this.dateTimeFormatters = dateTimeFormatters;
|
||||
this.dynamicTemplates = dynamicTemplates == null ? new XContentDynamicTemplate[0] : dynamicTemplates;
|
||||
this.dynamicTemplates = dynamicTemplates == null ? new DynamicTemplate[0] : dynamicTemplates;
|
||||
if (mappers != null) {
|
||||
this.mappers = copyOf(mappers);
|
||||
}
|
||||
|
@ -313,15 +313,15 @@ public class XContentObjectMapper implements XContentMapper, XContentIncludeInAl
|
|||
this.includeInAll = includeInAll;
|
||||
// when called from outside, apply this on all the inner mappers
|
||||
for (XContentMapper mapper : mappers.values()) {
|
||||
if (mapper instanceof XContentIncludeInAllMapper) {
|
||||
((XContentIncludeInAllMapper) mapper).includeInAll(includeInAll);
|
||||
if (mapper instanceof IncludeInAllMapper) {
|
||||
((IncludeInAllMapper) mapper).includeInAll(includeInAll);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public XContentObjectMapper putMapper(XContentMapper mapper) {
|
||||
if (mapper instanceof XContentIncludeInAllMapper) {
|
||||
((XContentIncludeInAllMapper) mapper).includeInAll(includeInAll);
|
||||
public ObjectMapper putMapper(XContentMapper mapper) {
|
||||
if (mapper instanceof IncludeInAllMapper) {
|
||||
((IncludeInAllMapper) mapper).includeInAll(includeInAll);
|
||||
}
|
||||
synchronized (mutex) {
|
||||
mappers = newMapBuilder(mappers).put(mapper.name(), mapper).immutableMap();
|
||||
|
@ -424,7 +424,7 @@ public class XContentObjectMapper implements XContentMapper, XContentIncludeInAl
|
|||
|
||||
private void serializeArray(ParseContext context, String lastFieldName) throws IOException {
|
||||
XContentMapper mapper = mappers.get(lastFieldName);
|
||||
if (mapper != null && mapper instanceof XContentArrayValueMapperParser) {
|
||||
if (mapper != null && mapper instanceof ArrayValueMapperParser) {
|
||||
mapper.parse(context);
|
||||
} else {
|
||||
XContentParser parser = context.parser();
|
||||
|
@ -564,16 +564,16 @@ public class XContentObjectMapper implements XContentMapper, XContentIncludeInAl
|
|||
}
|
||||
|
||||
private XContentMapper.Builder findTemplateBuilder(ParseContext context, String name, String dynamicType) {
|
||||
XContentDynamicTemplate dynamicTemplate = findTemplate(name, dynamicType);
|
||||
DynamicTemplate dynamicTemplate = findTemplate(name, dynamicType);
|
||||
if (dynamicTemplate == null) {
|
||||
return null;
|
||||
}
|
||||
XContentTypeParser.ParserContext parserContext = context.docMapperParser().parserContext();
|
||||
XContentMapper.TypeParser.ParserContext parserContext = context.docMapperParser().parserContext();
|
||||
return parserContext.typeParser(dynamicTemplate.mappingType(dynamicType)).parse(name, dynamicTemplate.mappingForName(name, dynamicType), parserContext);
|
||||
}
|
||||
|
||||
private XContentDynamicTemplate findTemplate(String name, String dynamicType) {
|
||||
for (XContentDynamicTemplate dynamicTemplate : dynamicTemplates) {
|
||||
private DynamicTemplate findTemplate(String name, String dynamicType) {
|
||||
for (DynamicTemplate dynamicTemplate : dynamicTemplates) {
|
||||
if (dynamicTemplate.match(name, dynamicType)) {
|
||||
return dynamicTemplate;
|
||||
}
|
||||
|
@ -582,15 +582,15 @@ public class XContentObjectMapper implements XContentMapper, XContentIncludeInAl
|
|||
}
|
||||
|
||||
@Override public void merge(XContentMapper mergeWith, MergeContext mergeContext) throws MergeMappingException {
|
||||
if (!(mergeWith instanceof XContentObjectMapper)) {
|
||||
if (!(mergeWith instanceof ObjectMapper)) {
|
||||
mergeContext.addConflict("Can't merge a non object mapping [" + mergeWith.name() + "] with an object mapping [" + name() + "]");
|
||||
return;
|
||||
}
|
||||
XContentObjectMapper mergeWithObject = (XContentObjectMapper) mergeWith;
|
||||
ObjectMapper mergeWithObject = (ObjectMapper) mergeWith;
|
||||
if (!mergeContext.mergeFlags().simulate()) {
|
||||
// merge them
|
||||
List<XContentDynamicTemplate> mergedTemplates = Lists.newArrayList(Arrays.asList(this.dynamicTemplates));
|
||||
for (XContentDynamicTemplate template : mergeWithObject.dynamicTemplates) {
|
||||
List<DynamicTemplate> mergedTemplates = Lists.newArrayList(Arrays.asList(this.dynamicTemplates));
|
||||
for (DynamicTemplate template : mergeWithObject.dynamicTemplates) {
|
||||
int index = mergedTemplates.indexOf(template);
|
||||
if (index == -1) {
|
||||
mergedTemplates.add(template);
|
||||
|
@ -598,7 +598,7 @@ public class XContentObjectMapper implements XContentMapper, XContentIncludeInAl
|
|||
mergedTemplates.set(index, template);
|
||||
}
|
||||
}
|
||||
this.dynamicTemplates = mergedTemplates.toArray(new XContentDynamicTemplate[mergedTemplates.size()]);
|
||||
this.dynamicTemplates = mergedTemplates.toArray(new DynamicTemplate[mergedTemplates.size()]);
|
||||
}
|
||||
synchronized (mutex) {
|
||||
for (XContentMapper mergeWithMapper : mergeWithObject.mappers.values()) {
|
||||
|
@ -607,19 +607,19 @@ public class XContentObjectMapper implements XContentMapper, XContentIncludeInAl
|
|||
// no mapping, simply add it if not simulating
|
||||
if (!mergeContext.mergeFlags().simulate()) {
|
||||
putMapper(mergeWithMapper);
|
||||
if (mergeWithMapper instanceof XContentFieldMapper) {
|
||||
if (mergeWithMapper instanceof AbstractFieldMapper) {
|
||||
mergeContext.docMapper().addFieldMapper((FieldMapper) mergeWithMapper);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if ((mergeWithMapper instanceof XContentMultiFieldMapper) && !(mergeIntoMapper instanceof XContentMultiFieldMapper)) {
|
||||
XContentMultiFieldMapper mergeWithMultiField = (XContentMultiFieldMapper) mergeWithMapper;
|
||||
if ((mergeWithMapper instanceof MultiFieldMapper) && !(mergeIntoMapper instanceof MultiFieldMapper)) {
|
||||
MultiFieldMapper mergeWithMultiField = (MultiFieldMapper) mergeWithMapper;
|
||||
mergeWithMultiField.merge(mergeIntoMapper, mergeContext);
|
||||
if (!mergeContext.mergeFlags().simulate()) {
|
||||
putMapper(mergeWithMultiField);
|
||||
// now, raise events for all mappers
|
||||
for (XContentMapper mapper : mergeWithMultiField.mappers().values()) {
|
||||
if (mapper instanceof XContentFieldMapper) {
|
||||
if (mapper instanceof AbstractFieldMapper) {
|
||||
mergeContext.docMapper().addFieldMapper((FieldMapper) mapper);
|
||||
}
|
||||
}
|
||||
|
@ -647,7 +647,7 @@ public class XContentObjectMapper implements XContentMapper, XContentIncludeInAl
|
|||
}
|
||||
if (dynamicTemplates != null && dynamicTemplates.length > 0) {
|
||||
builder.startArray("dynamic_templates");
|
||||
for (XContentDynamicTemplate dynamicTemplate : dynamicTemplates) {
|
||||
for (DynamicTemplate dynamicTemplate : dynamicTemplates) {
|
||||
builder.map(dynamicTemplate.conf());
|
||||
}
|
||||
builder.endArray();
|
|
@ -46,15 +46,15 @@ import static org.elasticsearch.index.mapper.xcontent.XContentTypeParsers.*;
|
|||
/**
|
||||
* @author kimchy (shay.banon)
|
||||
*/
|
||||
public class XContentShortFieldMapper extends XContentNumberFieldMapper<Short> {
|
||||
public class ShortFieldMapper extends NumberFieldMapper<Short> {
|
||||
|
||||
public static final String CONTENT_TYPE = "short";
|
||||
|
||||
public static class Defaults extends XContentNumberFieldMapper.Defaults {
|
||||
public static class Defaults extends NumberFieldMapper.Defaults {
|
||||
public static final Short NULL_VALUE = null;
|
||||
}
|
||||
|
||||
public static class Builder extends XContentNumberFieldMapper.Builder<Builder, XContentShortFieldMapper> {
|
||||
public static class Builder extends NumberFieldMapper.Builder<Builder, ShortFieldMapper> {
|
||||
|
||||
protected Short nullValue = Defaults.NULL_VALUE;
|
||||
|
||||
|
@ -68,17 +68,17 @@ public class XContentShortFieldMapper extends XContentNumberFieldMapper<Short> {
|
|||
return this;
|
||||
}
|
||||
|
||||
@Override public XContentShortFieldMapper build(BuilderContext context) {
|
||||
XContentShortFieldMapper fieldMapper = new XContentShortFieldMapper(buildNames(context),
|
||||
@Override public ShortFieldMapper build(BuilderContext context) {
|
||||
ShortFieldMapper fieldMapper = new ShortFieldMapper(buildNames(context),
|
||||
precisionStep, index, store, boost, omitNorms, omitTermFreqAndPositions, nullValue);
|
||||
fieldMapper.includeInAll(includeInAll);
|
||||
return fieldMapper;
|
||||
}
|
||||
}
|
||||
|
||||
public static class TypeParser implements XContentTypeParser {
|
||||
public static class TypeParser implements XContentMapper.TypeParser {
|
||||
@Override public XContentMapper.Builder parse(String name, Map<String, Object> node, ParserContext parserContext) throws MapperParsingException {
|
||||
XContentShortFieldMapper.Builder builder = shortField(name);
|
||||
ShortFieldMapper.Builder builder = shortField(name);
|
||||
parseNumberField(builder, name, node, parserContext);
|
||||
for (Map.Entry<String, Object> entry : node.entrySet()) {
|
||||
String propName = Strings.toUnderscoreCase(entry.getKey());
|
||||
|
@ -95,9 +95,9 @@ public class XContentShortFieldMapper extends XContentNumberFieldMapper<Short> {
|
|||
|
||||
private String nullValueAsString;
|
||||
|
||||
protected XContentShortFieldMapper(Names names, int precisionStep, Field.Index index, Field.Store store,
|
||||
float boost, boolean omitNorms, boolean omitTermFreqAndPositions,
|
||||
Short nullValue) {
|
||||
protected ShortFieldMapper(Names names, int precisionStep, Field.Index index, Field.Store store,
|
||||
float boost, boolean omitNorms, boolean omitTermFreqAndPositions,
|
||||
Short nullValue) {
|
||||
super(names, precisionStep, index, store, boost, omitNorms, omitTermFreqAndPositions,
|
||||
new NamedAnalyzer("_short/" + precisionStep, new NumericIntegerAnalyzer(precisionStep)),
|
||||
new NamedAnalyzer("_short/max", new NumericIntegerAnalyzer(Integer.MAX_VALUE)));
|
||||
|
@ -197,8 +197,8 @@ public class XContentShortFieldMapper extends XContentNumberFieldMapper<Short> {
|
|||
return;
|
||||
}
|
||||
if (!mergeContext.mergeFlags().simulate()) {
|
||||
this.nullValue = ((XContentShortFieldMapper) mergeWith).nullValue;
|
||||
this.nullValueAsString = ((XContentShortFieldMapper) mergeWith).nullValueAsString;
|
||||
this.nullValue = ((ShortFieldMapper) mergeWith).nullValue;
|
||||
this.nullValueAsString = ((ShortFieldMapper) mergeWith).nullValueAsString;
|
||||
}
|
||||
}
|
||||
|
|
@ -26,19 +26,18 @@ import org.elasticsearch.common.compress.lzf.LZFEncoder;
|
|||
import org.elasticsearch.common.lucene.Lucene;
|
||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||
import org.elasticsearch.index.mapper.MergeMappingException;
|
||||
import org.elasticsearch.index.mapper.SourceFieldMapper;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* @author kimchy (shay.banon)
|
||||
*/
|
||||
public class XContentSourceFieldMapper extends XContentFieldMapper<byte[]> implements SourceFieldMapper {
|
||||
public class SourceFieldMapper extends AbstractFieldMapper<byte[]> implements org.elasticsearch.index.mapper.SourceFieldMapper {
|
||||
|
||||
public static final String CONTENT_TYPE = "_source";
|
||||
|
||||
public static class Defaults extends XContentFieldMapper.Defaults {
|
||||
public static final String NAME = SourceFieldMapper.NAME;
|
||||
public static class Defaults extends AbstractFieldMapper.Defaults {
|
||||
public static final String NAME = org.elasticsearch.index.mapper.SourceFieldMapper.NAME;
|
||||
public static final boolean ENABLED = true;
|
||||
public static final Field.Index INDEX = Field.Index.NO;
|
||||
public static final Field.Store STORE = Field.Store.YES;
|
||||
|
@ -46,7 +45,7 @@ public class XContentSourceFieldMapper extends XContentFieldMapper<byte[]> imple
|
|||
public static final boolean OMIT_TERM_FREQ_AND_POSITIONS = true;
|
||||
}
|
||||
|
||||
public static class Builder extends XContentMapper.Builder<Builder, XContentSourceFieldMapper> {
|
||||
public static class Builder extends XContentMapper.Builder<Builder, SourceFieldMapper> {
|
||||
|
||||
private boolean enabled = Defaults.ENABLED;
|
||||
|
||||
|
@ -66,8 +65,8 @@ public class XContentSourceFieldMapper extends XContentFieldMapper<byte[]> imple
|
|||
return this;
|
||||
}
|
||||
|
||||
@Override public XContentSourceFieldMapper build(BuilderContext context) {
|
||||
return new XContentSourceFieldMapper(name, enabled, compress);
|
||||
@Override public SourceFieldMapper build(BuilderContext context) {
|
||||
return new SourceFieldMapper(name, enabled, compress);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -77,11 +76,11 @@ public class XContentSourceFieldMapper extends XContentFieldMapper<byte[]> imple
|
|||
|
||||
private final SourceFieldSelector fieldSelector;
|
||||
|
||||
protected XContentSourceFieldMapper() {
|
||||
protected SourceFieldMapper() {
|
||||
this(Defaults.NAME, Defaults.ENABLED, null);
|
||||
}
|
||||
|
||||
protected XContentSourceFieldMapper(String name, boolean enabled, Boolean compress) {
|
||||
protected SourceFieldMapper(String name, boolean enabled, Boolean compress) {
|
||||
super(new Names(name, name, name, name), Defaults.INDEX, Defaults.STORE, Defaults.TERM_VECTOR, Defaults.BOOST,
|
||||
Defaults.OMIT_NORMS, Defaults.OMIT_TERM_FREQ_AND_POSITIONS, Lucene.KEYWORD_ANALYZER, Lucene.KEYWORD_ANALYZER);
|
||||
this.enabled = enabled;
|
||||
|
@ -179,7 +178,7 @@ public class XContentSourceFieldMapper extends XContentFieldMapper<byte[]> imple
|
|||
}
|
||||
|
||||
@Override public void merge(XContentMapper mergeWith, MergeContext mergeContext) throws MergeMappingException {
|
||||
XContentSourceFieldMapper sourceMergeWith = (XContentSourceFieldMapper) mergeWith;
|
||||
SourceFieldMapper sourceMergeWith = (SourceFieldMapper) mergeWith;
|
||||
if (!mergeContext.mergeFlags().simulate()) {
|
||||
if (sourceMergeWith.compress != null) {
|
||||
this.compress = sourceMergeWith.compress;
|
|
@ -37,16 +37,16 @@ import static org.elasticsearch.index.mapper.xcontent.XContentTypeParsers.*;
|
|||
/**
|
||||
* @author kimchy (shay.banon)
|
||||
*/
|
||||
public class XContentStringFieldMapper extends XContentFieldMapper<String> implements XContentIncludeInAllMapper {
|
||||
public class StringFieldMapper extends AbstractFieldMapper<String> implements IncludeInAllMapper {
|
||||
|
||||
public static final String CONTENT_TYPE = "string";
|
||||
|
||||
public static class Defaults extends XContentFieldMapper.Defaults {
|
||||
public static class Defaults extends AbstractFieldMapper.Defaults {
|
||||
// NOTE, when adding defaults here, make sure you add them in the builder
|
||||
public static final String NULL_VALUE = null;
|
||||
}
|
||||
|
||||
public static class Builder extends XContentFieldMapper.OpenBuilder<Builder, XContentStringFieldMapper> {
|
||||
public static class Builder extends AbstractFieldMapper.OpenBuilder<Builder, StringFieldMapper> {
|
||||
|
||||
protected String nullValue = Defaults.NULL_VALUE;
|
||||
|
||||
|
@ -65,8 +65,8 @@ public class XContentStringFieldMapper extends XContentFieldMapper<String> imple
|
|||
return this;
|
||||
}
|
||||
|
||||
@Override public XContentStringFieldMapper build(BuilderContext context) {
|
||||
XContentStringFieldMapper fieldMapper = new XContentStringFieldMapper(buildNames(context),
|
||||
@Override public StringFieldMapper build(BuilderContext context) {
|
||||
StringFieldMapper fieldMapper = new StringFieldMapper(buildNames(context),
|
||||
index, store, termVector, boost, omitNorms, omitTermFreqAndPositions, nullValue,
|
||||
indexAnalyzer, searchAnalyzer);
|
||||
fieldMapper.includeInAll(includeInAll);
|
||||
|
@ -74,9 +74,9 @@ public class XContentStringFieldMapper extends XContentFieldMapper<String> imple
|
|||
}
|
||||
}
|
||||
|
||||
public static class TypeParser implements XContentTypeParser {
|
||||
public static class TypeParser implements XContentMapper.TypeParser {
|
||||
@Override public XContentMapper.Builder parse(String name, Map<String, Object> node, ParserContext parserContext) throws MapperParsingException {
|
||||
XContentStringFieldMapper.Builder builder = stringField(name);
|
||||
StringFieldMapper.Builder builder = stringField(name);
|
||||
parseField(builder, name, node, parserContext);
|
||||
for (Map.Entry<String, Object> entry : node.entrySet()) {
|
||||
String propName = Strings.toUnderscoreCase(entry.getKey());
|
||||
|
@ -94,9 +94,9 @@ public class XContentStringFieldMapper extends XContentFieldMapper<String> imple
|
|||
|
||||
private Boolean includeInAll;
|
||||
|
||||
protected XContentStringFieldMapper(Names names, Field.Index index, Field.Store store, Field.TermVector termVector,
|
||||
float boost, boolean omitNorms, boolean omitTermFreqAndPositions,
|
||||
String nullValue, NamedAnalyzer indexAnalyzer, NamedAnalyzer searchAnalyzer) {
|
||||
protected StringFieldMapper(Names names, Field.Index index, Field.Store store, Field.TermVector termVector,
|
||||
float boost, boolean omitNorms, boolean omitTermFreqAndPositions,
|
||||
String nullValue, NamedAnalyzer indexAnalyzer, NamedAnalyzer searchAnalyzer) {
|
||||
super(names, index, store, termVector, boost, omitNorms, omitTermFreqAndPositions, indexAnalyzer, searchAnalyzer);
|
||||
this.nullValue = nullValue;
|
||||
}
|
||||
|
@ -159,8 +159,8 @@ public class XContentStringFieldMapper extends XContentFieldMapper<String> imple
|
|||
return;
|
||||
}
|
||||
if (!mergeContext.mergeFlags().simulate()) {
|
||||
this.includeInAll = ((XContentStringFieldMapper) mergeWith).includeInAll;
|
||||
this.nullValue = ((XContentStringFieldMapper) mergeWith).nullValue;
|
||||
this.includeInAll = ((StringFieldMapper) mergeWith).includeInAll;
|
||||
this.nullValue = ((StringFieldMapper) mergeWith).nullValue;
|
||||
}
|
||||
}
|
||||
|
|
@ -26,27 +26,26 @@ import org.apache.lucene.index.Term;
|
|||
import org.elasticsearch.common.lucene.Lucene;
|
||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||
import org.elasticsearch.index.mapper.MergeMappingException;
|
||||
import org.elasticsearch.index.mapper.TypeFieldMapper;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* @author kimchy (shay.banon)
|
||||
*/
|
||||
public class XContentTypeFieldMapper extends XContentFieldMapper<String> implements TypeFieldMapper {
|
||||
public class TypeFieldMapper extends AbstractFieldMapper<String> implements org.elasticsearch.index.mapper.TypeFieldMapper {
|
||||
|
||||
public static final String CONTENT_TYPE = "_type";
|
||||
|
||||
public static class Defaults extends XContentFieldMapper.Defaults {
|
||||
public static final String NAME = TypeFieldMapper.NAME;
|
||||
public static final String INDEX_NAME = TypeFieldMapper.NAME;
|
||||
public static class Defaults extends AbstractFieldMapper.Defaults {
|
||||
public static final String NAME = org.elasticsearch.index.mapper.TypeFieldMapper.NAME;
|
||||
public static final String INDEX_NAME = org.elasticsearch.index.mapper.TypeFieldMapper.NAME;
|
||||
public static final Field.Index INDEX = Field.Index.NOT_ANALYZED;
|
||||
public static final Field.Store STORE = Field.Store.NO;
|
||||
public static final boolean OMIT_NORMS = true;
|
||||
public static final boolean OMIT_TERM_FREQ_AND_POSITIONS = true;
|
||||
}
|
||||
|
||||
public static class Builder extends XContentFieldMapper.Builder<Builder, XContentTypeFieldMapper> {
|
||||
public static class Builder extends AbstractFieldMapper.Builder<Builder, TypeFieldMapper> {
|
||||
|
||||
public Builder() {
|
||||
super(Defaults.NAME);
|
||||
|
@ -57,22 +56,22 @@ public class XContentTypeFieldMapper extends XContentFieldMapper<String> impleme
|
|||
omitTermFreqAndPositions = Defaults.OMIT_TERM_FREQ_AND_POSITIONS;
|
||||
}
|
||||
|
||||
@Override public XContentTypeFieldMapper build(BuilderContext context) {
|
||||
return new XContentTypeFieldMapper(name, indexName, store, termVector, boost, omitNorms, omitTermFreqAndPositions);
|
||||
@Override public TypeFieldMapper build(BuilderContext context) {
|
||||
return new TypeFieldMapper(name, indexName, store, termVector, boost, omitNorms, omitTermFreqAndPositions);
|
||||
}
|
||||
}
|
||||
|
||||
protected XContentTypeFieldMapper() {
|
||||
protected TypeFieldMapper() {
|
||||
this(Defaults.NAME, Defaults.INDEX_NAME);
|
||||
}
|
||||
|
||||
protected XContentTypeFieldMapper(String name, String indexName) {
|
||||
protected TypeFieldMapper(String name, String indexName) {
|
||||
this(name, indexName, Defaults.STORE, Defaults.TERM_VECTOR, Defaults.BOOST,
|
||||
Defaults.OMIT_NORMS, Defaults.OMIT_TERM_FREQ_AND_POSITIONS);
|
||||
}
|
||||
|
||||
public XContentTypeFieldMapper(String name, String indexName, Field.Store store, Field.TermVector termVector,
|
||||
float boost, boolean omitNorms, boolean omitTermFreqAndPositions) {
|
||||
public TypeFieldMapper(String name, String indexName, Field.Store store, Field.TermVector termVector,
|
||||
float boost, boolean omitNorms, boolean omitTermFreqAndPositions) {
|
||||
super(new Names(name, indexName, indexName, name), Defaults.INDEX, store, termVector, boost, omitNorms, omitTermFreqAndPositions,
|
||||
Lucene.KEYWORD_ANALYZER, Lucene.KEYWORD_ANALYZER);
|
||||
}
|
|
@ -27,25 +27,24 @@ import org.elasticsearch.common.xcontent.XContentBuilder;
|
|||
import org.elasticsearch.index.mapper.MapperParsingException;
|
||||
import org.elasticsearch.index.mapper.MergeMappingException;
|
||||
import org.elasticsearch.index.mapper.Uid;
|
||||
import org.elasticsearch.index.mapper.UidFieldMapper;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* @author kimchy (shay.banon)
|
||||
*/
|
||||
public class XContentUidFieldMapper extends XContentFieldMapper<Uid> implements UidFieldMapper {
|
||||
public class UidFieldMapper extends AbstractFieldMapper<Uid> implements org.elasticsearch.index.mapper.UidFieldMapper {
|
||||
|
||||
public static final String CONTENT_TYPE = "_uid";
|
||||
|
||||
public static class Defaults extends XContentFieldMapper.Defaults {
|
||||
public static final String NAME = UidFieldMapper.NAME;
|
||||
public static class Defaults extends AbstractFieldMapper.Defaults {
|
||||
public static final String NAME = org.elasticsearch.index.mapper.UidFieldMapper.NAME;
|
||||
public static final Field.Index INDEX = Field.Index.NOT_ANALYZED;
|
||||
public static final boolean OMIT_NORMS = true;
|
||||
public static final boolean OMIT_TERM_FREQ_AND_POSITIONS = true;
|
||||
}
|
||||
|
||||
public static class Builder extends XContentMapper.Builder<Builder, XContentUidFieldMapper> {
|
||||
public static class Builder extends XContentMapper.Builder<Builder, UidFieldMapper> {
|
||||
|
||||
protected String indexName;
|
||||
|
||||
|
@ -54,20 +53,20 @@ public class XContentUidFieldMapper extends XContentFieldMapper<Uid> implements
|
|||
this.indexName = name;
|
||||
}
|
||||
|
||||
@Override public XContentUidFieldMapper build(BuilderContext context) {
|
||||
return new XContentUidFieldMapper(name, indexName);
|
||||
@Override public UidFieldMapper build(BuilderContext context) {
|
||||
return new UidFieldMapper(name, indexName);
|
||||
}
|
||||
}
|
||||
|
||||
protected XContentUidFieldMapper() {
|
||||
protected UidFieldMapper() {
|
||||
this(Defaults.NAME);
|
||||
}
|
||||
|
||||
protected XContentUidFieldMapper(String name) {
|
||||
protected UidFieldMapper(String name) {
|
||||
this(name, name);
|
||||
}
|
||||
|
||||
protected XContentUidFieldMapper(String name, String indexName) {
|
||||
protected UidFieldMapper(String name, String indexName) {
|
||||
super(new Names(name, indexName, indexName, name), Defaults.INDEX, Field.Store.YES, Defaults.TERM_VECTOR, Defaults.BOOST,
|
||||
Defaults.OMIT_NORMS, Defaults.OMIT_TERM_FREQ_AND_POSITIONS, Lucene.KEYWORD_ANALYZER, Lucene.KEYWORD_ANALYZER);
|
||||
}
|
|
@ -44,19 +44,19 @@ public class XContentDocumentMapper implements DocumentMapper, ToXContent {
|
|||
|
||||
public static class Builder {
|
||||
|
||||
private XContentUidFieldMapper uidFieldMapper = new XContentUidFieldMapper();
|
||||
private UidFieldMapper uidFieldMapper = new UidFieldMapper();
|
||||
|
||||
private XContentIdFieldMapper idFieldMapper = new XContentIdFieldMapper();
|
||||
private IdFieldMapper idFieldMapper = new IdFieldMapper();
|
||||
|
||||
private XContentTypeFieldMapper typeFieldMapper = new XContentTypeFieldMapper();
|
||||
private TypeFieldMapper typeFieldMapper = new TypeFieldMapper();
|
||||
|
||||
private XContentIndexFieldMapper indexFieldMapper = new XContentIndexFieldMapper();
|
||||
private IndexFieldMapper indexFieldMapper = new IndexFieldMapper();
|
||||
|
||||
private XContentSourceFieldMapper sourceFieldMapper = new XContentSourceFieldMapper();
|
||||
private SourceFieldMapper sourceFieldMapper = new SourceFieldMapper();
|
||||
|
||||
private XContentBoostFieldMapper boostFieldMapper = new XContentBoostFieldMapper();
|
||||
private BoostFieldMapper boostFieldMapper = new BoostFieldMapper();
|
||||
|
||||
private XContentAllFieldMapper allFieldMapper = new XContentAllFieldMapper();
|
||||
private AllFieldMapper allFieldMapper = new AllFieldMapper();
|
||||
|
||||
private NamedAnalyzer indexAnalyzer;
|
||||
|
||||
|
@ -64,13 +64,13 @@ public class XContentDocumentMapper implements DocumentMapper, ToXContent {
|
|||
|
||||
private final String index;
|
||||
|
||||
private final XContentObjectMapper rootObjectMapper;
|
||||
private final ObjectMapper rootObjectMapper;
|
||||
|
||||
private ImmutableMap<String, Object> attributes = ImmutableMap.of();
|
||||
|
||||
private XContentMapper.BuilderContext builderContext = new XContentMapper.BuilderContext(new ContentPath(1));
|
||||
|
||||
public Builder(String index, XContentObjectMapper.Builder builder) {
|
||||
public Builder(String index, ObjectMapper.Builder builder) {
|
||||
this.index = index;
|
||||
this.rootObjectMapper = builder.build(builderContext);
|
||||
}
|
||||
|
@ -80,37 +80,37 @@ public class XContentDocumentMapper implements DocumentMapper, ToXContent {
|
|||
return this;
|
||||
}
|
||||
|
||||
public Builder sourceField(XContentSourceFieldMapper.Builder builder) {
|
||||
public Builder sourceField(SourceFieldMapper.Builder builder) {
|
||||
this.sourceFieldMapper = builder.build(builderContext);
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder idField(XContentIdFieldMapper.Builder builder) {
|
||||
public Builder idField(IdFieldMapper.Builder builder) {
|
||||
this.idFieldMapper = builder.build(builderContext);
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder uidField(XContentUidFieldMapper.Builder builder) {
|
||||
public Builder uidField(UidFieldMapper.Builder builder) {
|
||||
this.uidFieldMapper = builder.build(builderContext);
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder typeField(XContentTypeFieldMapper.Builder builder) {
|
||||
public Builder typeField(TypeFieldMapper.Builder builder) {
|
||||
this.typeFieldMapper = builder.build(builderContext);
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder indexField(XContentIndexFieldMapper.Builder builder) {
|
||||
public Builder indexField(IndexFieldMapper.Builder builder) {
|
||||
this.indexFieldMapper = builder.build(builderContext);
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder boostField(XContentBoostFieldMapper.Builder builder) {
|
||||
public Builder boostField(BoostFieldMapper.Builder builder) {
|
||||
this.boostFieldMapper = builder.build(builderContext);
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder allField(XContentAllFieldMapper.Builder builder) {
|
||||
public Builder allField(AllFieldMapper.Builder builder) {
|
||||
this.allFieldMapper = builder.build(builderContext);
|
||||
return this;
|
||||
}
|
||||
|
@ -157,21 +157,21 @@ public class XContentDocumentMapper implements DocumentMapper, ToXContent {
|
|||
|
||||
private volatile CompressedString mappingSource;
|
||||
|
||||
private final XContentUidFieldMapper uidFieldMapper;
|
||||
private final UidFieldMapper uidFieldMapper;
|
||||
|
||||
private final XContentIdFieldMapper idFieldMapper;
|
||||
private final IdFieldMapper idFieldMapper;
|
||||
|
||||
private final XContentTypeFieldMapper typeFieldMapper;
|
||||
private final TypeFieldMapper typeFieldMapper;
|
||||
|
||||
private final XContentIndexFieldMapper indexFieldMapper;
|
||||
private final IndexFieldMapper indexFieldMapper;
|
||||
|
||||
private final XContentSourceFieldMapper sourceFieldMapper;
|
||||
private final SourceFieldMapper sourceFieldMapper;
|
||||
|
||||
private final XContentBoostFieldMapper boostFieldMapper;
|
||||
private final BoostFieldMapper boostFieldMapper;
|
||||
|
||||
private final XContentAllFieldMapper allFieldMapper;
|
||||
private final AllFieldMapper allFieldMapper;
|
||||
|
||||
private final XContentObjectMapper rootObjectMapper;
|
||||
private final ObjectMapper rootObjectMapper;
|
||||
|
||||
private final Analyzer indexAnalyzer;
|
||||
|
||||
|
@ -186,16 +186,16 @@ public class XContentDocumentMapper implements DocumentMapper, ToXContent {
|
|||
private final Object mutex = new Object();
|
||||
|
||||
public XContentDocumentMapper(String index, XContentDocumentMapperParser docMapperParser,
|
||||
XContentObjectMapper rootObjectMapper,
|
||||
ObjectMapper rootObjectMapper,
|
||||
ImmutableMap<String, Object> attributes,
|
||||
XContentUidFieldMapper uidFieldMapper,
|
||||
XContentIdFieldMapper idFieldMapper,
|
||||
XContentTypeFieldMapper typeFieldMapper,
|
||||
XContentIndexFieldMapper indexFieldMapper,
|
||||
XContentSourceFieldMapper sourceFieldMapper,
|
||||
XContentAllFieldMapper allFieldMapper,
|
||||
UidFieldMapper uidFieldMapper,
|
||||
IdFieldMapper idFieldMapper,
|
||||
TypeFieldMapper typeFieldMapper,
|
||||
IndexFieldMapper indexFieldMapper,
|
||||
SourceFieldMapper sourceFieldMapper,
|
||||
AllFieldMapper allFieldMapper,
|
||||
Analyzer indexAnalyzer, Analyzer searchAnalyzer,
|
||||
@Nullable XContentBoostFieldMapper boostFieldMapper) {
|
||||
@Nullable BoostFieldMapper boostFieldMapper) {
|
||||
this.index = index;
|
||||
this.type = rootObjectMapper.name();
|
||||
this.docMapperParser = docMapperParser;
|
||||
|
@ -260,31 +260,31 @@ public class XContentDocumentMapper implements DocumentMapper, ToXContent {
|
|||
return this.mappingSource;
|
||||
}
|
||||
|
||||
@Override public UidFieldMapper uidMapper() {
|
||||
@Override public org.elasticsearch.index.mapper.UidFieldMapper uidMapper() {
|
||||
return this.uidFieldMapper;
|
||||
}
|
||||
|
||||
@Override public IdFieldMapper idMapper() {
|
||||
@Override public org.elasticsearch.index.mapper.IdFieldMapper idMapper() {
|
||||
return this.idFieldMapper;
|
||||
}
|
||||
|
||||
@Override public IndexFieldMapper indexMapper() {
|
||||
@Override public org.elasticsearch.index.mapper.IndexFieldMapper indexMapper() {
|
||||
return this.indexFieldMapper;
|
||||
}
|
||||
|
||||
@Override public TypeFieldMapper typeMapper() {
|
||||
@Override public org.elasticsearch.index.mapper.TypeFieldMapper typeMapper() {
|
||||
return this.typeFieldMapper;
|
||||
}
|
||||
|
||||
@Override public SourceFieldMapper sourceMapper() {
|
||||
@Override public org.elasticsearch.index.mapper.SourceFieldMapper sourceMapper() {
|
||||
return this.sourceFieldMapper;
|
||||
}
|
||||
|
||||
@Override public BoostFieldMapper boostMapper() {
|
||||
@Override public org.elasticsearch.index.mapper.BoostFieldMapper boostMapper() {
|
||||
return this.boostFieldMapper;
|
||||
}
|
||||
|
||||
@Override public AllFieldMapper allFieldMapper() {
|
||||
@Override public org.elasticsearch.index.mapper.AllFieldMapper allFieldMapper() {
|
||||
return this.allFieldMapper;
|
||||
}
|
||||
|
||||
|
|
|
@ -52,11 +52,11 @@ public class XContentDocumentMapperParser extends AbstractIndexComponent impleme
|
|||
|
||||
private final AnalysisService analysisService;
|
||||
|
||||
private final XContentObjectMapper.TypeParser rootObjectTypeParser = new XContentObjectMapper.TypeParser();
|
||||
private final ObjectMapper.TypeParser rootObjectTypeParser = new ObjectMapper.TypeParser();
|
||||
|
||||
private final Object typeParsersMutex = new Object();
|
||||
|
||||
private volatile ImmutableMap<String, XContentTypeParser> typeParsers;
|
||||
private volatile ImmutableMap<String, XContentMapper.TypeParser> typeParsers;
|
||||
|
||||
public XContentDocumentMapperParser(Index index, AnalysisService analysisService) {
|
||||
this(index, ImmutableSettings.Builder.EMPTY_SETTINGS, analysisService);
|
||||
|
@ -65,33 +65,33 @@ public class XContentDocumentMapperParser extends AbstractIndexComponent impleme
|
|||
public XContentDocumentMapperParser(Index index, @IndexSettings Settings indexSettings, AnalysisService analysisService) {
|
||||
super(index, indexSettings);
|
||||
this.analysisService = analysisService;
|
||||
typeParsers = new MapBuilder<String, XContentTypeParser>()
|
||||
.put(XContentShortFieldMapper.CONTENT_TYPE, new XContentShortFieldMapper.TypeParser())
|
||||
.put(XContentIntegerFieldMapper.CONTENT_TYPE, new XContentIntegerFieldMapper.TypeParser())
|
||||
.put(XContentLongFieldMapper.CONTENT_TYPE, new XContentLongFieldMapper.TypeParser())
|
||||
.put(XContentFloatFieldMapper.CONTENT_TYPE, new XContentFloatFieldMapper.TypeParser())
|
||||
.put(XContentDoubleFieldMapper.CONTENT_TYPE, new XContentDoubleFieldMapper.TypeParser())
|
||||
.put(XContentBooleanFieldMapper.CONTENT_TYPE, new XContentBooleanFieldMapper.TypeParser())
|
||||
.put(XContentBinaryFieldMapper.CONTENT_TYPE, new XContentBinaryFieldMapper.TypeParser())
|
||||
.put(XContentDateFieldMapper.CONTENT_TYPE, new XContentDateFieldMapper.TypeParser())
|
||||
.put(XContentStringFieldMapper.CONTENT_TYPE, new XContentStringFieldMapper.TypeParser())
|
||||
.put(XContentObjectMapper.CONTENT_TYPE, new XContentObjectMapper.TypeParser())
|
||||
.put(XContentMultiFieldMapper.CONTENT_TYPE, new XContentMultiFieldMapper.TypeParser())
|
||||
.put(XContentGeoPointFieldMapper.CONTENT_TYPE, new XContentGeoPointFieldMapper.TypeParser())
|
||||
typeParsers = new MapBuilder<String, XContentMapper.TypeParser>()
|
||||
.put(ShortFieldMapper.CONTENT_TYPE, new ShortFieldMapper.TypeParser())
|
||||
.put(IntegerFieldMapper.CONTENT_TYPE, new IntegerFieldMapper.TypeParser())
|
||||
.put(LongFieldMapper.CONTENT_TYPE, new LongFieldMapper.TypeParser())
|
||||
.put(FloatFieldMapper.CONTENT_TYPE, new FloatFieldMapper.TypeParser())
|
||||
.put(DoubleFieldMapper.CONTENT_TYPE, new DoubleFieldMapper.TypeParser())
|
||||
.put(BooleanFieldMapper.CONTENT_TYPE, new BooleanFieldMapper.TypeParser())
|
||||
.put(BinaryFieldMapper.CONTENT_TYPE, new BinaryFieldMapper.TypeParser())
|
||||
.put(DateFieldMapper.CONTENT_TYPE, new DateFieldMapper.TypeParser())
|
||||
.put(StringFieldMapper.CONTENT_TYPE, new StringFieldMapper.TypeParser())
|
||||
.put(ObjectMapper.CONTENT_TYPE, new ObjectMapper.TypeParser())
|
||||
.put(MultiFieldMapper.CONTENT_TYPE, new MultiFieldMapper.TypeParser())
|
||||
.put(GeoPointFieldMapper.CONTENT_TYPE, new GeoPointFieldMapper.TypeParser())
|
||||
.immutableMap();
|
||||
}
|
||||
|
||||
public void putTypeParser(String type, XContentTypeParser typeParser) {
|
||||
public void putTypeParser(String type, XContentMapper.TypeParser typeParser) {
|
||||
synchronized (typeParsersMutex) {
|
||||
typeParsers = new MapBuilder<String, XContentTypeParser>()
|
||||
typeParsers = new MapBuilder<String, XContentMapper.TypeParser>()
|
||||
.putAll(typeParsers)
|
||||
.put(type, typeParser)
|
||||
.immutableMap();
|
||||
}
|
||||
}
|
||||
|
||||
public XContentTypeParser.ParserContext parserContext() {
|
||||
return new XContentTypeParser.ParserContext(analysisService, typeParsers);
|
||||
public XContentMapper.TypeParser.ParserContext parserContext() {
|
||||
return new XContentMapper.TypeParser.ParserContext(analysisService, typeParsers);
|
||||
}
|
||||
|
||||
@Override public XContentDocumentMapper parse(String source) throws MapperParsingException {
|
||||
|
@ -124,27 +124,27 @@ public class XContentDocumentMapperParser extends AbstractIndexComponent impleme
|
|||
}
|
||||
}
|
||||
|
||||
XContentTypeParser.ParserContext parserContext = new XContentTypeParser.ParserContext(analysisService, typeParsers);
|
||||
XContentMapper.TypeParser.ParserContext parserContext = new XContentMapper.TypeParser.ParserContext(analysisService, typeParsers);
|
||||
|
||||
XContentDocumentMapper.Builder docBuilder = doc(index.name(), (XContentObjectMapper.Builder) rootObjectTypeParser.parse(type, mapping, parserContext));
|
||||
XContentDocumentMapper.Builder docBuilder = doc(index.name(), (ObjectMapper.Builder) rootObjectTypeParser.parse(type, mapping, parserContext));
|
||||
|
||||
for (Map.Entry<String, Object> entry : mapping.entrySet()) {
|
||||
String fieldName = Strings.toUnderscoreCase(entry.getKey());
|
||||
Object fieldNode = entry.getValue();
|
||||
|
||||
if (XContentSourceFieldMapper.CONTENT_TYPE.equals(fieldName) || "sourceField".equals(fieldName)) {
|
||||
if (SourceFieldMapper.CONTENT_TYPE.equals(fieldName) || "sourceField".equals(fieldName)) {
|
||||
docBuilder.sourceField(parseSourceField((Map<String, Object>) fieldNode, parserContext));
|
||||
} else if (XContentIdFieldMapper.CONTENT_TYPE.equals(fieldName) || "idField".equals(fieldName)) {
|
||||
} else if (IdFieldMapper.CONTENT_TYPE.equals(fieldName) || "idField".equals(fieldName)) {
|
||||
docBuilder.idField(parseIdField((Map<String, Object>) fieldNode, parserContext));
|
||||
} else if (XContentIndexFieldMapper.CONTENT_TYPE.equals(fieldName) || "indexField".equals(fieldName)) {
|
||||
} else if (IndexFieldMapper.CONTENT_TYPE.equals(fieldName) || "indexField".equals(fieldName)) {
|
||||
docBuilder.indexField(parseIndexField((Map<String, Object>) fieldNode, parserContext));
|
||||
} else if (XContentTypeFieldMapper.CONTENT_TYPE.equals(fieldName) || "typeField".equals(fieldName)) {
|
||||
} else if (TypeFieldMapper.CONTENT_TYPE.equals(fieldName) || "typeField".equals(fieldName)) {
|
||||
docBuilder.typeField(parseTypeField((Map<String, Object>) fieldNode, parserContext));
|
||||
} else if (XContentUidFieldMapper.CONTENT_TYPE.equals(fieldName) || "uidField".equals(fieldName)) {
|
||||
} else if (UidFieldMapper.CONTENT_TYPE.equals(fieldName) || "uidField".equals(fieldName)) {
|
||||
docBuilder.uidField(parseUidField((Map<String, Object>) fieldNode, parserContext));
|
||||
} else if (XContentBoostFieldMapper.CONTENT_TYPE.equals(fieldName) || "boostField".equals(fieldName)) {
|
||||
} else if (BoostFieldMapper.CONTENT_TYPE.equals(fieldName) || "boostField".equals(fieldName)) {
|
||||
docBuilder.boostField(parseBoostField((Map<String, Object>) fieldNode, parserContext));
|
||||
} else if (XContentAllFieldMapper.CONTENT_TYPE.equals(fieldName) || "allField".equals(fieldName)) {
|
||||
} else if (AllFieldMapper.CONTENT_TYPE.equals(fieldName) || "allField".equals(fieldName)) {
|
||||
docBuilder.allField(parseAllField((Map<String, Object>) fieldNode, parserContext));
|
||||
} else if ("index_analyzer".equals(fieldName)) {
|
||||
docBuilder.indexAnalyzer(analysisService.analyzer(fieldNode.toString()));
|
||||
|
@ -175,14 +175,14 @@ public class XContentDocumentMapperParser extends AbstractIndexComponent impleme
|
|||
return documentMapper;
|
||||
}
|
||||
|
||||
private XContentUidFieldMapper.Builder parseUidField(Map<String, Object> uidNode, XContentTypeParser.ParserContext parserContext) {
|
||||
XContentUidFieldMapper.Builder builder = uid();
|
||||
private UidFieldMapper.Builder parseUidField(Map<String, Object> uidNode, XContentMapper.TypeParser.ParserContext parserContext) {
|
||||
UidFieldMapper.Builder builder = uid();
|
||||
return builder;
|
||||
}
|
||||
|
||||
private XContentBoostFieldMapper.Builder parseBoostField(Map<String, Object> boostNode, XContentTypeParser.ParserContext parserContext) {
|
||||
String name = boostNode.get("name") == null ? XContentBoostFieldMapper.Defaults.NAME : boostNode.get("name").toString();
|
||||
XContentBoostFieldMapper.Builder builder = boost(name);
|
||||
private BoostFieldMapper.Builder parseBoostField(Map<String, Object> boostNode, XContentMapper.TypeParser.ParserContext parserContext) {
|
||||
String name = boostNode.get("name") == null ? BoostFieldMapper.Defaults.NAME : boostNode.get("name").toString();
|
||||
BoostFieldMapper.Builder builder = boost(name);
|
||||
parseNumberField(builder, name, boostNode, parserContext);
|
||||
for (Map.Entry<String, Object> entry : boostNode.entrySet()) {
|
||||
String propName = Strings.toUnderscoreCase(entry.getKey());
|
||||
|
@ -194,21 +194,21 @@ public class XContentDocumentMapperParser extends AbstractIndexComponent impleme
|
|||
return builder;
|
||||
}
|
||||
|
||||
private XContentTypeFieldMapper.Builder parseTypeField(Map<String, Object> typeNode, XContentTypeParser.ParserContext parserContext) {
|
||||
XContentTypeFieldMapper.Builder builder = type();
|
||||
private TypeFieldMapper.Builder parseTypeField(Map<String, Object> typeNode, XContentMapper.TypeParser.ParserContext parserContext) {
|
||||
TypeFieldMapper.Builder builder = type();
|
||||
parseField(builder, builder.name, typeNode, parserContext);
|
||||
return builder;
|
||||
}
|
||||
|
||||
|
||||
private XContentIdFieldMapper.Builder parseIdField(Map<String, Object> idNode, XContentTypeParser.ParserContext parserContext) {
|
||||
XContentIdFieldMapper.Builder builder = id();
|
||||
private IdFieldMapper.Builder parseIdField(Map<String, Object> idNode, XContentMapper.TypeParser.ParserContext parserContext) {
|
||||
IdFieldMapper.Builder builder = id();
|
||||
parseField(builder, builder.name, idNode, parserContext);
|
||||
return builder;
|
||||
}
|
||||
|
||||
private XContentAllFieldMapper.Builder parseAllField(Map<String, Object> allNode, XContentTypeParser.ParserContext parserContext) {
|
||||
XContentAllFieldMapper.Builder builder = all();
|
||||
private AllFieldMapper.Builder parseAllField(Map<String, Object> allNode, XContentMapper.TypeParser.ParserContext parserContext) {
|
||||
AllFieldMapper.Builder builder = all();
|
||||
parseField(builder, builder.name, allNode, parserContext);
|
||||
for (Map.Entry<String, Object> entry : allNode.entrySet()) {
|
||||
String fieldName = Strings.toUnderscoreCase(entry.getKey());
|
||||
|
@ -220,8 +220,8 @@ public class XContentDocumentMapperParser extends AbstractIndexComponent impleme
|
|||
return builder;
|
||||
}
|
||||
|
||||
private XContentSourceFieldMapper.Builder parseSourceField(Map<String, Object> sourceNode, XContentTypeParser.ParserContext parserContext) {
|
||||
XContentSourceFieldMapper.Builder builder = source();
|
||||
private SourceFieldMapper.Builder parseSourceField(Map<String, Object> sourceNode, XContentMapper.TypeParser.ParserContext parserContext) {
|
||||
SourceFieldMapper.Builder builder = source();
|
||||
|
||||
for (Map.Entry<String, Object> entry : sourceNode.entrySet()) {
|
||||
String fieldName = Strings.toUnderscoreCase(entry.getKey());
|
||||
|
@ -235,8 +235,8 @@ public class XContentDocumentMapperParser extends AbstractIndexComponent impleme
|
|||
return builder;
|
||||
}
|
||||
|
||||
private XContentIndexFieldMapper.Builder parseIndexField(Map<String, Object> indexNode, XContentTypeParser.ParserContext parserContext) {
|
||||
XContentIndexFieldMapper.Builder builder = XContentMapperBuilders.index();
|
||||
private IndexFieldMapper.Builder parseIndexField(Map<String, Object> indexNode, XContentMapper.TypeParser.ParserContext parserContext) {
|
||||
IndexFieldMapper.Builder builder = XContentMapperBuilders.index();
|
||||
parseField(builder, builder.name, indexNode, parserContext);
|
||||
|
||||
for (Map.Entry<String, Object> entry : indexNode.entrySet()) {
|
||||
|
|
|
@ -19,13 +19,18 @@
|
|||
|
||||
package org.elasticsearch.index.mapper.xcontent;
|
||||
|
||||
import org.elasticsearch.common.Strings;
|
||||
import org.elasticsearch.common.collect.ImmutableMap;
|
||||
import org.elasticsearch.common.util.concurrent.NotThreadSafe;
|
||||
import org.elasticsearch.common.util.concurrent.ThreadSafe;
|
||||
import org.elasticsearch.common.xcontent.ToXContent;
|
||||
import org.elasticsearch.index.analysis.AnalysisService;
|
||||
import org.elasticsearch.index.mapper.FieldMapperListener;
|
||||
import org.elasticsearch.index.mapper.MapperParsingException;
|
||||
import org.elasticsearch.index.mapper.MergeMappingException;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author kimchy (shay.banon)
|
||||
|
@ -62,6 +67,31 @@ public interface XContentMapper extends ToXContent {
|
|||
public abstract Y build(BuilderContext context);
|
||||
}
|
||||
|
||||
public interface TypeParser {
|
||||
|
||||
public static class ParserContext {
|
||||
|
||||
private final AnalysisService analysisService;
|
||||
|
||||
private final ImmutableMap<String, TypeParser> typeParsers;
|
||||
|
||||
public ParserContext(AnalysisService analysisService, ImmutableMap<String, TypeParser> typeParsers) {
|
||||
this.analysisService = analysisService;
|
||||
this.typeParsers = typeParsers;
|
||||
}
|
||||
|
||||
public AnalysisService analysisService() {
|
||||
return analysisService;
|
||||
}
|
||||
|
||||
public TypeParser typeParser(String type) {
|
||||
return typeParsers.get(Strings.toUnderscoreCase(type));
|
||||
}
|
||||
}
|
||||
|
||||
XContentMapper.Builder parse(String name, Map<String, Object> node, ParserContext parserContext) throws MapperParsingException;
|
||||
}
|
||||
|
||||
String name();
|
||||
|
||||
void parse(ParseContext context) throws IOException;
|
||||
|
|
|
@ -28,79 +28,79 @@ public final class XContentMapperBuilders {
|
|||
|
||||
}
|
||||
|
||||
public static XContentDocumentMapper.Builder doc(String index, XContentObjectMapper.Builder objectBuilder) {
|
||||
public static XContentDocumentMapper.Builder doc(String index, ObjectMapper.Builder objectBuilder) {
|
||||
return new XContentDocumentMapper.Builder(index, objectBuilder);
|
||||
}
|
||||
|
||||
public static XContentSourceFieldMapper.Builder source() {
|
||||
return new XContentSourceFieldMapper.Builder();
|
||||
public static SourceFieldMapper.Builder source() {
|
||||
return new SourceFieldMapper.Builder();
|
||||
}
|
||||
|
||||
public static XContentIdFieldMapper.Builder id() {
|
||||
return new XContentIdFieldMapper.Builder();
|
||||
public static IdFieldMapper.Builder id() {
|
||||
return new IdFieldMapper.Builder();
|
||||
}
|
||||
|
||||
public static XContentUidFieldMapper.Builder uid() {
|
||||
return new XContentUidFieldMapper.Builder();
|
||||
public static UidFieldMapper.Builder uid() {
|
||||
return new UidFieldMapper.Builder();
|
||||
}
|
||||
|
||||
public static XContentTypeFieldMapper.Builder type() {
|
||||
return new XContentTypeFieldMapper.Builder();
|
||||
public static TypeFieldMapper.Builder type() {
|
||||
return new TypeFieldMapper.Builder();
|
||||
}
|
||||
|
||||
public static XContentIndexFieldMapper.Builder index() {
|
||||
return new XContentIndexFieldMapper.Builder();
|
||||
public static IndexFieldMapper.Builder index() {
|
||||
return new IndexFieldMapper.Builder();
|
||||
}
|
||||
|
||||
public static XContentBoostFieldMapper.Builder boost(String name) {
|
||||
return new XContentBoostFieldMapper.Builder(name);
|
||||
public static BoostFieldMapper.Builder boost(String name) {
|
||||
return new BoostFieldMapper.Builder(name);
|
||||
}
|
||||
|
||||
public static XContentAllFieldMapper.Builder all() {
|
||||
return new XContentAllFieldMapper.Builder();
|
||||
public static AllFieldMapper.Builder all() {
|
||||
return new AllFieldMapper.Builder();
|
||||
}
|
||||
|
||||
public static XContentMultiFieldMapper.Builder multiField(String name) {
|
||||
return new XContentMultiFieldMapper.Builder(name);
|
||||
public static MultiFieldMapper.Builder multiField(String name) {
|
||||
return new MultiFieldMapper.Builder(name);
|
||||
}
|
||||
|
||||
public static XContentObjectMapper.Builder object(String name) {
|
||||
return new XContentObjectMapper.Builder(name);
|
||||
public static ObjectMapper.Builder object(String name) {
|
||||
return new ObjectMapper.Builder(name);
|
||||
}
|
||||
|
||||
public static XContentBooleanFieldMapper.Builder booleanField(String name) {
|
||||
return new XContentBooleanFieldMapper.Builder(name);
|
||||
public static BooleanFieldMapper.Builder booleanField(String name) {
|
||||
return new BooleanFieldMapper.Builder(name);
|
||||
}
|
||||
|
||||
public static XContentStringFieldMapper.Builder stringField(String name) {
|
||||
return new XContentStringFieldMapper.Builder(name);
|
||||
public static StringFieldMapper.Builder stringField(String name) {
|
||||
return new StringFieldMapper.Builder(name);
|
||||
}
|
||||
|
||||
public static XContentBinaryFieldMapper.Builder binaryField(String name) {
|
||||
return new XContentBinaryFieldMapper.Builder(name);
|
||||
public static BinaryFieldMapper.Builder binaryField(String name) {
|
||||
return new BinaryFieldMapper.Builder(name);
|
||||
}
|
||||
|
||||
public static XContentDateFieldMapper.Builder dateField(String name) {
|
||||
return new XContentDateFieldMapper.Builder(name);
|
||||
public static DateFieldMapper.Builder dateField(String name) {
|
||||
return new DateFieldMapper.Builder(name);
|
||||
}
|
||||
|
||||
public static XContentShortFieldMapper.Builder shortField(String name) {
|
||||
return new XContentShortFieldMapper.Builder(name);
|
||||
public static ShortFieldMapper.Builder shortField(String name) {
|
||||
return new ShortFieldMapper.Builder(name);
|
||||
}
|
||||
|
||||
public static XContentIntegerFieldMapper.Builder integerField(String name) {
|
||||
return new XContentIntegerFieldMapper.Builder(name);
|
||||
public static IntegerFieldMapper.Builder integerField(String name) {
|
||||
return new IntegerFieldMapper.Builder(name);
|
||||
}
|
||||
|
||||
public static XContentLongFieldMapper.Builder longField(String name) {
|
||||
return new XContentLongFieldMapper.Builder(name);
|
||||
public static LongFieldMapper.Builder longField(String name) {
|
||||
return new LongFieldMapper.Builder(name);
|
||||
}
|
||||
|
||||
public static XContentFloatFieldMapper.Builder floatField(String name) {
|
||||
return new XContentFloatFieldMapper.Builder(name);
|
||||
public static FloatFieldMapper.Builder floatField(String name) {
|
||||
return new FloatFieldMapper.Builder(name);
|
||||
}
|
||||
|
||||
public static XContentDoubleFieldMapper.Builder doubleField(String name) {
|
||||
return new XContentDoubleFieldMapper.Builder(name);
|
||||
public static DoubleFieldMapper.Builder doubleField(String name) {
|
||||
return new DoubleFieldMapper.Builder(name);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,55 +0,0 @@
|
|||
/*
|
||||
* Licensed to Elastic Search and Shay Banon under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. Elastic Search licenses this
|
||||
* file to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package org.elasticsearch.index.mapper.xcontent;
|
||||
|
||||
import org.elasticsearch.common.Strings;
|
||||
import org.elasticsearch.common.collect.ImmutableMap;
|
||||
import org.elasticsearch.index.analysis.AnalysisService;
|
||||
import org.elasticsearch.index.mapper.MapperParsingException;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author kimchy (shay.banon)
|
||||
*/
|
||||
public interface XContentTypeParser {
|
||||
|
||||
public static class ParserContext {
|
||||
|
||||
private final AnalysisService analysisService;
|
||||
|
||||
private final ImmutableMap<String, XContentTypeParser> typeParsers;
|
||||
|
||||
public ParserContext(AnalysisService analysisService, ImmutableMap<String, XContentTypeParser> typeParsers) {
|
||||
this.analysisService = analysisService;
|
||||
this.typeParsers = typeParsers;
|
||||
}
|
||||
|
||||
public AnalysisService analysisService() {
|
||||
return analysisService;
|
||||
}
|
||||
|
||||
public XContentTypeParser typeParser(String type) {
|
||||
return typeParsers.get(Strings.toUnderscoreCase(type));
|
||||
}
|
||||
}
|
||||
|
||||
XContentMapper.Builder parse(String name, Map<String, Object> node, ParserContext parserContext) throws MapperParsingException;
|
||||
}
|
|
@ -35,7 +35,7 @@ import static org.elasticsearch.common.xcontent.support.XContentMapValues.*;
|
|||
*/
|
||||
public class XContentTypeParsers {
|
||||
|
||||
public static void parseNumberField(XContentNumberFieldMapper.Builder builder, String name, Map<String, Object> numberNode, XContentTypeParser.ParserContext parserContext) {
|
||||
public static void parseNumberField(NumberFieldMapper.Builder builder, String name, Map<String, Object> numberNode, XContentMapper.TypeParser.ParserContext parserContext) {
|
||||
parseField(builder, name, numberNode, parserContext);
|
||||
for (Map.Entry<String, Object> entry : numberNode.entrySet()) {
|
||||
String propName = Strings.toUnderscoreCase(entry.getKey());
|
||||
|
@ -46,7 +46,7 @@ public class XContentTypeParsers {
|
|||
}
|
||||
}
|
||||
|
||||
public static void parseField(XContentFieldMapper.Builder builder, String name, Map<String, Object> fieldNode, XContentTypeParser.ParserContext parserContext) {
|
||||
public static void parseField(AbstractFieldMapper.Builder builder, String name, Map<String, Object> fieldNode, XContentMapper.TypeParser.ParserContext parserContext) {
|
||||
for (Map.Entry<String, Object> entry : fieldNode.entrySet()) {
|
||||
String propName = Strings.toUnderscoreCase(entry.getKey());
|
||||
Object propNode = entry.getValue();
|
||||
|
|
|
@ -29,7 +29,7 @@ import org.elasticsearch.index.AbstractIndexComponent;
|
|||
import org.elasticsearch.index.Index;
|
||||
import org.elasticsearch.index.mapper.FieldMapper;
|
||||
import org.elasticsearch.index.mapper.MapperService;
|
||||
import org.elasticsearch.index.mapper.xcontent.XContentGeoPointFieldMapper;
|
||||
import org.elasticsearch.index.mapper.xcontent.GeoPointFieldMapper;
|
||||
import org.elasticsearch.index.query.QueryParsingException;
|
||||
import org.elasticsearch.index.settings.IndexSettings;
|
||||
|
||||
|
@ -67,8 +67,8 @@ public class GeoBoundingBoxFilterParser extends AbstractIndexComponent implement
|
|||
if (token == XContentParser.Token.FIELD_NAME) {
|
||||
currentFieldName = parser.currentName();
|
||||
} else if (token == XContentParser.Token.START_OBJECT) {
|
||||
latFieldName = currentFieldName + XContentGeoPointFieldMapper.Names.LAT_SUFFIX;
|
||||
lonFieldName = currentFieldName + XContentGeoPointFieldMapper.Names.LON_SUFFIX;
|
||||
latFieldName = currentFieldName + GeoPointFieldMapper.Names.LAT_SUFFIX;
|
||||
lonFieldName = currentFieldName + GeoPointFieldMapper.Names.LON_SUFFIX;
|
||||
|
||||
while ((token = parser.nextToken()) != XContentParser.Token.END_OBJECT) {
|
||||
if (token == XContentParser.Token.FIELD_NAME) {
|
||||
|
@ -103,11 +103,11 @@ public class GeoBoundingBoxFilterParser extends AbstractIndexComponent implement
|
|||
if (token == XContentParser.Token.FIELD_NAME) {
|
||||
currentFieldName = parser.currentName();
|
||||
} else if (token.isValue()) {
|
||||
if (currentFieldName.equals(XContentGeoPointFieldMapper.Names.LAT)) {
|
||||
if (currentFieldName.equals(GeoPointFieldMapper.Names.LAT)) {
|
||||
point.lat = parser.doubleValue();
|
||||
} else if (currentFieldName.equals(XContentGeoPointFieldMapper.Names.LON)) {
|
||||
} else if (currentFieldName.equals(GeoPointFieldMapper.Names.LON)) {
|
||||
point.lon = parser.doubleValue();
|
||||
} else if (currentFieldName.equals(XContentGeoPointFieldMapper.Names.GEOHASH)) {
|
||||
} else if (currentFieldName.equals(GeoPointFieldMapper.Names.GEOHASH)) {
|
||||
double[] values = GeoHashUtils.decode(parser.text());
|
||||
point.lat = values[0];
|
||||
point.lon = values[1];
|
||||
|
@ -117,8 +117,8 @@ public class GeoBoundingBoxFilterParser extends AbstractIndexComponent implement
|
|||
}
|
||||
} else if (token.isValue()) {
|
||||
if ("field".equals(currentFieldName)) {
|
||||
latFieldName = parser.text() + XContentGeoPointFieldMapper.Names.LAT_SUFFIX;
|
||||
lonFieldName = parser.text() + XContentGeoPointFieldMapper.Names.LON_SUFFIX;
|
||||
latFieldName = parser.text() + GeoPointFieldMapper.Names.LAT_SUFFIX;
|
||||
lonFieldName = parser.text() + GeoPointFieldMapper.Names.LON_SUFFIX;
|
||||
} else {
|
||||
GeoBoundingBoxFilter.Point point = null;
|
||||
if ("top_left".equals(currentFieldName) || "topLeft".equals(currentFieldName)) {
|
||||
|
|
|
@ -31,7 +31,7 @@ import org.elasticsearch.index.AbstractIndexComponent;
|
|||
import org.elasticsearch.index.Index;
|
||||
import org.elasticsearch.index.mapper.FieldMapper;
|
||||
import org.elasticsearch.index.mapper.MapperService;
|
||||
import org.elasticsearch.index.mapper.xcontent.XContentGeoPointFieldMapper;
|
||||
import org.elasticsearch.index.mapper.xcontent.GeoPointFieldMapper;
|
||||
import org.elasticsearch.index.query.QueryParsingException;
|
||||
import org.elasticsearch.index.settings.IndexSettings;
|
||||
|
||||
|
@ -86,22 +86,22 @@ public class GeoDistanceFilterParser extends AbstractIndexComponent implements X
|
|||
while ((token = parser.nextToken()) != XContentParser.Token.END_ARRAY) {
|
||||
|
||||
}
|
||||
latFieldName = currentFieldName + "." + XContentGeoPointFieldMapper.Names.LAT;
|
||||
lonFieldName = currentFieldName + "." + XContentGeoPointFieldMapper.Names.LON;
|
||||
latFieldName = currentFieldName + "." + GeoPointFieldMapper.Names.LAT;
|
||||
lonFieldName = currentFieldName + "." + GeoPointFieldMapper.Names.LON;
|
||||
} else if (token == XContentParser.Token.START_OBJECT) {
|
||||
// the json in the format of -> field : { lat : 30, lon : 12 }
|
||||
String currentName = parser.currentName();
|
||||
latFieldName = currentFieldName + XContentGeoPointFieldMapper.Names.LAT_SUFFIX;
|
||||
lonFieldName = currentFieldName + XContentGeoPointFieldMapper.Names.LON_SUFFIX;
|
||||
latFieldName = currentFieldName + GeoPointFieldMapper.Names.LAT_SUFFIX;
|
||||
lonFieldName = currentFieldName + GeoPointFieldMapper.Names.LON_SUFFIX;
|
||||
while ((token = parser.nextToken()) != XContentParser.Token.END_OBJECT) {
|
||||
if (token == XContentParser.Token.FIELD_NAME) {
|
||||
currentName = parser.currentName();
|
||||
} else if (token.isValue()) {
|
||||
if (currentName.equals(XContentGeoPointFieldMapper.Names.LAT)) {
|
||||
if (currentName.equals(GeoPointFieldMapper.Names.LAT)) {
|
||||
lat = parser.doubleValue();
|
||||
} else if (currentName.equals(XContentGeoPointFieldMapper.Names.LON)) {
|
||||
} else if (currentName.equals(GeoPointFieldMapper.Names.LON)) {
|
||||
lon = parser.doubleValue();
|
||||
} else if (currentName.equals(XContentGeoPointFieldMapper.Names.GEOHASH)) {
|
||||
} else if (currentName.equals(GeoPointFieldMapper.Names.GEOHASH)) {
|
||||
double[] values = GeoHashUtils.decode(parser.text());
|
||||
lat = values[0];
|
||||
lon = values[1];
|
||||
|
@ -119,18 +119,18 @@ public class GeoDistanceFilterParser extends AbstractIndexComponent implements X
|
|||
unit = DistanceUnit.fromString(parser.text());
|
||||
} else if (currentFieldName.equals("distance_type") || currentFieldName.equals("distanceType")) {
|
||||
geoDistance = GeoDistance.fromString(parser.text());
|
||||
} else if (currentFieldName.endsWith(XContentGeoPointFieldMapper.Names.LAT_SUFFIX)) {
|
||||
} else if (currentFieldName.endsWith(GeoPointFieldMapper.Names.LAT_SUFFIX)) {
|
||||
lat = parser.doubleValue();
|
||||
latFieldName = currentFieldName;
|
||||
} else if (currentFieldName.endsWith(XContentGeoPointFieldMapper.Names.LON_SUFFIX)) {
|
||||
} else if (currentFieldName.endsWith(GeoPointFieldMapper.Names.LON_SUFFIX)) {
|
||||
lon = parser.doubleValue();
|
||||
lonFieldName = currentFieldName;
|
||||
} else if (currentFieldName.endsWith(XContentGeoPointFieldMapper.Names.GEOHASH_SUFFIX)) {
|
||||
} else if (currentFieldName.endsWith(GeoPointFieldMapper.Names.GEOHASH_SUFFIX)) {
|
||||
double[] values = GeoHashUtils.decode(parser.text());
|
||||
lat = values[0];
|
||||
lon = values[1];
|
||||
latFieldName = currentFieldName.substring(0, currentFieldName.length() - XContentGeoPointFieldMapper.Names.GEOHASH_SUFFIX.length()) + XContentGeoPointFieldMapper.Names.LAT_SUFFIX;
|
||||
lonFieldName = currentFieldName.substring(0, currentFieldName.length() - XContentGeoPointFieldMapper.Names.GEOHASH_SUFFIX.length()) + XContentGeoPointFieldMapper.Names.LON_SUFFIX;
|
||||
latFieldName = currentFieldName.substring(0, currentFieldName.length() - GeoPointFieldMapper.Names.GEOHASH_SUFFIX.length()) + GeoPointFieldMapper.Names.LAT_SUFFIX;
|
||||
lonFieldName = currentFieldName.substring(0, currentFieldName.length() - GeoPointFieldMapper.Names.GEOHASH_SUFFIX.length()) + GeoPointFieldMapper.Names.LON_SUFFIX;
|
||||
} else if ("_name".equals(currentFieldName)) {
|
||||
filterName = parser.text();
|
||||
} else {
|
||||
|
@ -146,8 +146,8 @@ public class GeoDistanceFilterParser extends AbstractIndexComponent implements X
|
|||
lon = values[1];
|
||||
}
|
||||
|
||||
latFieldName = currentFieldName + XContentGeoPointFieldMapper.Names.LAT_SUFFIX;
|
||||
lonFieldName = currentFieldName + XContentGeoPointFieldMapper.Names.LON_SUFFIX;
|
||||
latFieldName = currentFieldName + GeoPointFieldMapper.Names.LAT_SUFFIX;
|
||||
lonFieldName = currentFieldName + GeoPointFieldMapper.Names.LON_SUFFIX;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -30,7 +30,7 @@ import org.elasticsearch.index.AbstractIndexComponent;
|
|||
import org.elasticsearch.index.Index;
|
||||
import org.elasticsearch.index.mapper.FieldMapper;
|
||||
import org.elasticsearch.index.mapper.MapperService;
|
||||
import org.elasticsearch.index.mapper.xcontent.XContentGeoPointFieldMapper;
|
||||
import org.elasticsearch.index.mapper.xcontent.GeoPointFieldMapper;
|
||||
import org.elasticsearch.index.query.QueryParsingException;
|
||||
import org.elasticsearch.index.settings.IndexSettings;
|
||||
|
||||
|
@ -81,8 +81,8 @@ public class GeoPolygonFilterParser extends AbstractIndexComponent implements XC
|
|||
if (token == XContentParser.Token.FIELD_NAME) {
|
||||
currentFieldName = parser.currentName();
|
||||
} else if (token == XContentParser.Token.START_OBJECT) {
|
||||
latFieldName = currentFieldName + XContentGeoPointFieldMapper.Names.LAT_SUFFIX;
|
||||
lonFieldName = currentFieldName + XContentGeoPointFieldMapper.Names.LON_SUFFIX;
|
||||
latFieldName = currentFieldName + GeoPointFieldMapper.Names.LAT_SUFFIX;
|
||||
lonFieldName = currentFieldName + GeoPointFieldMapper.Names.LON_SUFFIX;
|
||||
|
||||
while ((token = parser.nextToken()) != XContentParser.Token.END_OBJECT) {
|
||||
if (token == XContentParser.Token.FIELD_NAME) {
|
||||
|
@ -108,11 +108,11 @@ public class GeoPolygonFilterParser extends AbstractIndexComponent implements XC
|
|||
if (token == XContentParser.Token.FIELD_NAME) {
|
||||
currentFieldName = parser.currentName();
|
||||
} else if (token.isValue()) {
|
||||
if (currentFieldName.equals(XContentGeoPointFieldMapper.Names.LAT)) {
|
||||
if (currentFieldName.equals(GeoPointFieldMapper.Names.LAT)) {
|
||||
point.lat = parser.doubleValue();
|
||||
} else if (currentFieldName.equals(XContentGeoPointFieldMapper.Names.LON)) {
|
||||
} else if (currentFieldName.equals(GeoPointFieldMapper.Names.LON)) {
|
||||
point.lon = parser.doubleValue();
|
||||
} else if (currentFieldName.equals(XContentGeoPointFieldMapper.Names.GEOHASH)) {
|
||||
} else if (currentFieldName.equals(GeoPointFieldMapper.Names.GEOHASH)) {
|
||||
double[] values = GeoHashUtils.decode(parser.text());
|
||||
point.lat = values[0];
|
||||
point.lon = values[1];
|
||||
|
|
|
@ -27,7 +27,7 @@ import org.elasticsearch.index.field.data.FieldDataType;
|
|||
import org.elasticsearch.index.field.data.NumericFieldData;
|
||||
import org.elasticsearch.index.mapper.FieldMapper;
|
||||
import org.elasticsearch.index.mapper.MapperService;
|
||||
import org.elasticsearch.index.mapper.xcontent.XContentGeoPointFieldMapper;
|
||||
import org.elasticsearch.index.mapper.xcontent.GeoPointFieldMapper;
|
||||
import org.elasticsearch.search.facets.Facet;
|
||||
import org.elasticsearch.search.facets.FacetPhaseExecutionException;
|
||||
import org.elasticsearch.search.facets.support.AbstractFacetCollector;
|
||||
|
@ -75,7 +75,7 @@ public class GeoDistanceFacetCollector extends AbstractFacetCollector {
|
|||
this.geoDistance = geoDistance;
|
||||
this.fieldDataCache = context.fieldDataCache();
|
||||
|
||||
MapperService.SmartNameFieldMappers smartMappers = context.mapperService().smartName(fieldName + XContentGeoPointFieldMapper.Names.LAT_SUFFIX);
|
||||
MapperService.SmartNameFieldMappers smartMappers = context.mapperService().smartName(fieldName + GeoPointFieldMapper.Names.LAT_SUFFIX);
|
||||
if (smartMappers == null || !smartMappers.hasMapper()) {
|
||||
throw new FacetPhaseExecutionException(facetName, "No mapping found for field [" + fieldName + "]");
|
||||
}
|
||||
|
@ -87,7 +87,7 @@ public class GeoDistanceFacetCollector extends AbstractFacetCollector {
|
|||
|
||||
this.indexLatFieldName = smartMappers.mapper().names().indexName();
|
||||
|
||||
FieldMapper mapper = context.mapperService().smartNameFieldMapper(fieldName + XContentGeoPointFieldMapper.Names.LON_SUFFIX);
|
||||
FieldMapper mapper = context.mapperService().smartNameFieldMapper(fieldName + GeoPointFieldMapper.Names.LON_SUFFIX);
|
||||
if (mapper == null) {
|
||||
throw new FacetPhaseExecutionException(facetName, "No mapping found for field [" + fieldName + "]");
|
||||
}
|
||||
|
|
|
@ -25,7 +25,7 @@ import org.elasticsearch.common.lucene.geo.GeoHashUtils;
|
|||
import org.elasticsearch.common.thread.ThreadLocals;
|
||||
import org.elasticsearch.common.unit.DistanceUnit;
|
||||
import org.elasticsearch.common.xcontent.XContentParser;
|
||||
import org.elasticsearch.index.mapper.xcontent.XContentGeoPointFieldMapper;
|
||||
import org.elasticsearch.index.mapper.xcontent.GeoPointFieldMapper;
|
||||
import org.elasticsearch.search.facets.FacetPhaseExecutionException;
|
||||
import org.elasticsearch.search.facets.collector.FacetCollector;
|
||||
import org.elasticsearch.search.facets.collector.FacetCollectorParser;
|
||||
|
@ -113,11 +113,11 @@ public class GeoDistanceFacetCollectorParser implements FacetCollectorParser {
|
|||
if (token == XContentParser.Token.FIELD_NAME) {
|
||||
currentName = parser.currentName();
|
||||
} else if (token.isValue()) {
|
||||
if (currentName.equals(XContentGeoPointFieldMapper.Names.LAT)) {
|
||||
if (currentName.equals(GeoPointFieldMapper.Names.LAT)) {
|
||||
lat = parser.doubleValue();
|
||||
} else if (currentName.equals(XContentGeoPointFieldMapper.Names.LON)) {
|
||||
} else if (currentName.equals(GeoPointFieldMapper.Names.LON)) {
|
||||
lon = parser.doubleValue();
|
||||
} else if (currentName.equals(XContentGeoPointFieldMapper.Names.GEOHASH)) {
|
||||
} else if (currentName.equals(GeoPointFieldMapper.Names.GEOHASH)) {
|
||||
double[] values = GeoHashUtils.decode(parser.text());
|
||||
lat = values[0];
|
||||
lon = values[1];
|
||||
|
|
|
@ -25,7 +25,7 @@ import org.elasticsearch.common.lucene.geo.GeoDistanceDataComparator;
|
|||
import org.elasticsearch.common.lucene.geo.GeoHashUtils;
|
||||
import org.elasticsearch.common.unit.DistanceUnit;
|
||||
import org.elasticsearch.common.xcontent.XContentParser;
|
||||
import org.elasticsearch.index.mapper.xcontent.XContentGeoPointFieldMapper;
|
||||
import org.elasticsearch.index.mapper.xcontent.GeoPointFieldMapper;
|
||||
import org.elasticsearch.search.internal.SearchContext;
|
||||
|
||||
/**
|
||||
|
@ -67,11 +67,11 @@ public class GeoDistanceSortParser implements SortParser {
|
|||
if (token == XContentParser.Token.FIELD_NAME) {
|
||||
currentName = parser.currentName();
|
||||
} else if (token.isValue()) {
|
||||
if (currentName.equals(XContentGeoPointFieldMapper.Names.LAT)) {
|
||||
if (currentName.equals(GeoPointFieldMapper.Names.LAT)) {
|
||||
lat = parser.doubleValue();
|
||||
} else if (currentName.equals(XContentGeoPointFieldMapper.Names.LON)) {
|
||||
} else if (currentName.equals(GeoPointFieldMapper.Names.LON)) {
|
||||
lon = parser.doubleValue();
|
||||
} else if (currentName.equals(XContentGeoPointFieldMapper.Names.GEOHASH)) {
|
||||
} else if (currentName.equals(GeoPointFieldMapper.Names.GEOHASH)) {
|
||||
double[] values = GeoHashUtils.decode(parser.text());
|
||||
lat = values[0];
|
||||
lon = values[1];
|
||||
|
|
|
@ -28,7 +28,7 @@ import org.elasticsearch.index.mapper.MapperService;
|
|||
/**
|
||||
* @author kimchy (shay.banon)
|
||||
*/
|
||||
public class XContentMapperTests {
|
||||
public class MapperTests {
|
||||
|
||||
public static XContentDocumentMapperParser newParser() {
|
||||
return new XContentDocumentMapperParser(new Index("test"), new AnalysisService(new Index("test")));
|
|
@ -23,8 +23,8 @@ import org.apache.lucene.document.Document;
|
|||
import org.elasticsearch.common.lucene.all.AllEntries;
|
||||
import org.elasticsearch.common.lucene.all.AllField;
|
||||
import org.elasticsearch.common.lucene.all.AllTokenStream;
|
||||
import org.elasticsearch.index.mapper.xcontent.MapperTests;
|
||||
import org.elasticsearch.index.mapper.xcontent.XContentDocumentMapper;
|
||||
import org.elasticsearch.index.mapper.xcontent.XContentMapperTests;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import static org.elasticsearch.common.io.Streams.*;
|
||||
|
@ -39,7 +39,7 @@ public class SimpleAllMapperTests {
|
|||
|
||||
@Test public void testSimpleAllMappers() throws Exception {
|
||||
String mapping = copyToStringFromClasspath("/org/elasticsearch/index/mapper/xcontent/all/mapping.json");
|
||||
XContentDocumentMapper docMapper = XContentMapperTests.newParser().parse(mapping);
|
||||
XContentDocumentMapper docMapper = MapperTests.newParser().parse(mapping);
|
||||
byte[] json = copyToBytesFromClasspath("/org/elasticsearch/index/mapper/xcontent/all/test1.json");
|
||||
Document doc = docMapper.parse(json).doc();
|
||||
AllField field = (AllField) doc.getFieldable("_all");
|
||||
|
@ -51,11 +51,11 @@ public class SimpleAllMapperTests {
|
|||
|
||||
@Test public void testSimpleAllMappersWithReparse() throws Exception {
|
||||
String mapping = copyToStringFromClasspath("/org/elasticsearch/index/mapper/xcontent/all/mapping.json");
|
||||
XContentDocumentMapper docMapper = XContentMapperTests.newParser().parse(mapping);
|
||||
XContentDocumentMapper docMapper = MapperTests.newParser().parse(mapping);
|
||||
String builtMapping = docMapper.mappingSource().string();
|
||||
// System.out.println(builtMapping);
|
||||
// reparse it
|
||||
XContentDocumentMapper builtDocMapper = XContentMapperTests.newParser().parse(builtMapping);
|
||||
XContentDocumentMapper builtDocMapper = MapperTests.newParser().parse(builtMapping);
|
||||
byte[] json = copyToBytesFromClasspath("/org/elasticsearch/index/mapper/xcontent/all/test1.json");
|
||||
Document doc = builtDocMapper.parse(json).doc();
|
||||
|
||||
|
@ -68,7 +68,7 @@ public class SimpleAllMapperTests {
|
|||
|
||||
@Test public void testSimpleAllMappersWithStore() throws Exception {
|
||||
String mapping = copyToStringFromClasspath("/org/elasticsearch/index/mapper/xcontent/all/store-mapping.json");
|
||||
XContentDocumentMapper docMapper = XContentMapperTests.newParser().parse(mapping);
|
||||
XContentDocumentMapper docMapper = MapperTests.newParser().parse(mapping);
|
||||
byte[] json = copyToBytesFromClasspath("/org/elasticsearch/index/mapper/xcontent/all/test1.json");
|
||||
Document doc = docMapper.parse(json).doc();
|
||||
AllField field = (AllField) doc.getFieldable("_all");
|
||||
|
@ -83,11 +83,11 @@ public class SimpleAllMapperTests {
|
|||
|
||||
@Test public void testSimpleAllMappersWithReparseWithStore() throws Exception {
|
||||
String mapping = copyToStringFromClasspath("/org/elasticsearch/index/mapper/xcontent/all/store-mapping.json");
|
||||
XContentDocumentMapper docMapper = XContentMapperTests.newParser().parse(mapping);
|
||||
XContentDocumentMapper docMapper = MapperTests.newParser().parse(mapping);
|
||||
String builtMapping = docMapper.mappingSource().string();
|
||||
System.out.println(builtMapping);
|
||||
// reparse it
|
||||
XContentDocumentMapper builtDocMapper = XContentMapperTests.newParser().parse(builtMapping);
|
||||
XContentDocumentMapper builtDocMapper = MapperTests.newParser().parse(builtMapping);
|
||||
byte[] json = copyToBytesFromClasspath("/org/elasticsearch/index/mapper/xcontent/all/test1.json");
|
||||
Document doc = builtDocMapper.parse(json).doc();
|
||||
|
||||
|
|
|
@ -22,8 +22,8 @@ package org.elasticsearch.index.mapper.xcontent.defaultsource;
|
|||
import org.elasticsearch.common.xcontent.XContentFactory;
|
||||
import org.elasticsearch.index.mapper.MapperParsingException;
|
||||
import org.elasticsearch.index.mapper.MapperService;
|
||||
import org.elasticsearch.index.mapper.xcontent.MapperTests;
|
||||
import org.elasticsearch.index.mapper.xcontent.XContentDocumentMapper;
|
||||
import org.elasticsearch.index.mapper.xcontent.XContentMapperTests;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import static org.hamcrest.MatcherAssert.*;
|
||||
|
@ -39,12 +39,12 @@ public class DefaultSourceMappingTests {
|
|||
.startObject("_source").field("enabled", false).endObject()
|
||||
.endObject().endObject().string();
|
||||
|
||||
XContentDocumentMapper mapper = XContentMapperTests.newParser().parse("my_type", null, defaultMapping);
|
||||
XContentDocumentMapper mapper = MapperTests.newParser().parse("my_type", null, defaultMapping);
|
||||
assertThat(mapper.type(), equalTo("my_type"));
|
||||
assertThat(mapper.sourceMapper().enabled(), equalTo(false));
|
||||
|
||||
try {
|
||||
mapper = XContentMapperTests.newParser().parse(null, null, defaultMapping);
|
||||
mapper = MapperTests.newParser().parse(null, null, defaultMapping);
|
||||
assertThat(mapper.type(), equalTo("my_type"));
|
||||
assertThat(mapper.sourceMapper().enabled(), equalTo(false));
|
||||
assert false;
|
||||
|
@ -62,7 +62,7 @@ public class DefaultSourceMappingTests {
|
|||
.startObject("_source").field("enabled", true).endObject()
|
||||
.endObject().endObject().string();
|
||||
|
||||
XContentDocumentMapper mapper = XContentMapperTests.newParser().parse("my_type", mapping, defaultMapping);
|
||||
XContentDocumentMapper mapper = MapperTests.newParser().parse("my_type", mapping, defaultMapping);
|
||||
assertThat(mapper.type(), equalTo("my_type"));
|
||||
assertThat(mapper.sourceMapper().enabled(), equalTo(true));
|
||||
}
|
||||
|
@ -72,7 +72,7 @@ public class DefaultSourceMappingTests {
|
|||
.startObject("_source").field("enabled", false).endObject()
|
||||
.endObject().endObject().string();
|
||||
|
||||
MapperService mapperService = XContentMapperTests.newMapperService();
|
||||
MapperService mapperService = MapperTests.newMapperService();
|
||||
mapperService.add(MapperService.DEFAULT_MAPPING, defaultMapping);
|
||||
|
||||
XContentDocumentMapper mapper = (XContentDocumentMapper) mapperService.type("my_type");
|
||||
|
@ -85,7 +85,7 @@ public class DefaultSourceMappingTests {
|
|||
.startObject("_source").field("enabled", false).endObject()
|
||||
.endObject().endObject().string();
|
||||
|
||||
MapperService mapperService = XContentMapperTests.newMapperService();
|
||||
MapperService mapperService = MapperTests.newMapperService();
|
||||
mapperService.add(MapperService.DEFAULT_MAPPING, defaultMapping);
|
||||
|
||||
String mapping = XContentFactory.jsonBuilder().startObject().startObject("type")
|
||||
|
|
|
@ -22,8 +22,8 @@ package org.elasticsearch.index.mapper.xcontent.dynamictemplate.genericstore;
|
|||
import org.apache.lucene.document.Document;
|
||||
import org.apache.lucene.document.Field;
|
||||
import org.elasticsearch.index.mapper.FieldMappers;
|
||||
import org.elasticsearch.index.mapper.xcontent.MapperTests;
|
||||
import org.elasticsearch.index.mapper.xcontent.XContentDocumentMapper;
|
||||
import org.elasticsearch.index.mapper.xcontent.XContentMapperTests;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import static org.elasticsearch.common.io.Streams.*;
|
||||
|
@ -37,7 +37,7 @@ public class GenericStoreDynamicTempalteTests {
|
|||
|
||||
@Test public void testSimple() throws Exception {
|
||||
String mapping = copyToStringFromClasspath("/org/elasticsearch/index/mapper/xcontent/dynamictemplate/genericstore/test-mapping.json");
|
||||
XContentDocumentMapper docMapper = XContentMapperTests.newParser().parse(mapping);
|
||||
XContentDocumentMapper docMapper = MapperTests.newParser().parse(mapping);
|
||||
byte[] json = copyToBytesFromClasspath("/org/elasticsearch/index/mapper/xcontent/dynamictemplate/genericstore/test-data.json");
|
||||
Document doc = docMapper.parse(json).doc();
|
||||
|
||||
|
|
|
@ -22,8 +22,8 @@ package org.elasticsearch.index.mapper.xcontent.dynamictemplate.simple;
|
|||
import org.apache.lucene.document.Document;
|
||||
import org.apache.lucene.document.Field;
|
||||
import org.elasticsearch.index.mapper.FieldMappers;
|
||||
import org.elasticsearch.index.mapper.xcontent.MapperTests;
|
||||
import org.elasticsearch.index.mapper.xcontent.XContentDocumentMapper;
|
||||
import org.elasticsearch.index.mapper.xcontent.XContentMapperTests;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import static org.elasticsearch.common.io.Streams.*;
|
||||
|
@ -37,7 +37,7 @@ public class SimpleDynamicTemplatesTests {
|
|||
|
||||
@Test public void testSimple() throws Exception {
|
||||
String mapping = copyToStringFromClasspath("/org/elasticsearch/index/mapper/xcontent/dynamictemplate/simple/test-mapping.json");
|
||||
XContentDocumentMapper docMapper = XContentMapperTests.newParser().parse(mapping);
|
||||
XContentDocumentMapper docMapper = MapperTests.newParser().parse(mapping);
|
||||
byte[] json = copyToBytesFromClasspath("/org/elasticsearch/index/mapper/xcontent/dynamictemplate/simple/test-data.json");
|
||||
Document doc = docMapper.parse(json).doc();
|
||||
|
||||
|
|
|
@ -22,8 +22,8 @@ package org.elasticsearch.index.mapper.xcontent.geopoint;
|
|||
import org.elasticsearch.common.lucene.geo.GeoHashUtils;
|
||||
import org.elasticsearch.common.xcontent.XContentFactory;
|
||||
import org.elasticsearch.index.mapper.ParsedDocument;
|
||||
import org.elasticsearch.index.mapper.xcontent.MapperTests;
|
||||
import org.elasticsearch.index.mapper.xcontent.XContentDocumentMapper;
|
||||
import org.elasticsearch.index.mapper.xcontent.XContentMapperTests;
|
||||
import org.hamcrest.MatcherAssert;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
|
@ -39,7 +39,7 @@ public class GeohashMappingGeoPointTests {
|
|||
.startObject("properties").startObject("point").field("type", "geo_point").field("geohash", true).field("lat_lon", false).endObject().endObject()
|
||||
.endObject().endObject().string();
|
||||
|
||||
XContentDocumentMapper defaultMapper = XContentMapperTests.newParser().parse(mapping);
|
||||
XContentDocumentMapper defaultMapper = MapperTests.newParser().parse(mapping);
|
||||
|
||||
ParsedDocument doc = defaultMapper.parse("type", "1", XContentFactory.jsonBuilder()
|
||||
.startObject()
|
||||
|
@ -57,7 +57,7 @@ public class GeohashMappingGeoPointTests {
|
|||
.startObject("properties").startObject("point").field("type", "geo_point").field("geohash", true).field("lat_lon", false).endObject().endObject()
|
||||
.endObject().endObject().string();
|
||||
|
||||
XContentDocumentMapper defaultMapper = XContentMapperTests.newParser().parse(mapping);
|
||||
XContentDocumentMapper defaultMapper = MapperTests.newParser().parse(mapping);
|
||||
|
||||
ParsedDocument doc = defaultMapper.parse("type", "1", XContentFactory.jsonBuilder()
|
||||
.startObject()
|
||||
|
@ -75,7 +75,7 @@ public class GeohashMappingGeoPointTests {
|
|||
.startObject("properties").startObject("point").field("type", "geo_point").field("geohash", true).field("lat_lon", false).endObject().endObject()
|
||||
.endObject().endObject().string();
|
||||
|
||||
XContentDocumentMapper defaultMapper = XContentMapperTests.newParser().parse(mapping);
|
||||
XContentDocumentMapper defaultMapper = MapperTests.newParser().parse(mapping);
|
||||
|
||||
ParsedDocument doc = defaultMapper.parse("type", "1", XContentFactory.jsonBuilder()
|
||||
.startObject()
|
||||
|
|
|
@ -22,8 +22,8 @@ package org.elasticsearch.index.mapper.xcontent.geopoint;
|
|||
import org.elasticsearch.common.lucene.geo.GeoHashUtils;
|
||||
import org.elasticsearch.common.xcontent.XContentFactory;
|
||||
import org.elasticsearch.index.mapper.ParsedDocument;
|
||||
import org.elasticsearch.index.mapper.xcontent.MapperTests;
|
||||
import org.elasticsearch.index.mapper.xcontent.XContentDocumentMapper;
|
||||
import org.elasticsearch.index.mapper.xcontent.XContentMapperTests;
|
||||
import org.hamcrest.MatcherAssert;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
|
@ -39,7 +39,7 @@ public class LatLonAndGeohashMappingGeoPointTests {
|
|||
.startObject("properties").startObject("point").field("type", "geo_point").field("geohash", true).endObject().endObject()
|
||||
.endObject().endObject().string();
|
||||
|
||||
XContentDocumentMapper defaultMapper = XContentMapperTests.newParser().parse(mapping);
|
||||
XContentDocumentMapper defaultMapper = MapperTests.newParser().parse(mapping);
|
||||
|
||||
ParsedDocument doc = defaultMapper.parse("type", "1", XContentFactory.jsonBuilder()
|
||||
.startObject()
|
||||
|
@ -57,7 +57,7 @@ public class LatLonAndGeohashMappingGeoPointTests {
|
|||
.startObject("properties").startObject("point").field("type", "geo_point").field("geohash", true).endObject().endObject()
|
||||
.endObject().endObject().string();
|
||||
|
||||
XContentDocumentMapper defaultMapper = XContentMapperTests.newParser().parse(mapping);
|
||||
XContentDocumentMapper defaultMapper = MapperTests.newParser().parse(mapping);
|
||||
|
||||
ParsedDocument doc = defaultMapper.parse("type", "1", XContentFactory.jsonBuilder()
|
||||
.startObject()
|
||||
|
@ -75,7 +75,7 @@ public class LatLonAndGeohashMappingGeoPointTests {
|
|||
.startObject("properties").startObject("point").field("type", "geo_point").field("geohash", true).endObject().endObject()
|
||||
.endObject().endObject().string();
|
||||
|
||||
XContentDocumentMapper defaultMapper = XContentMapperTests.newParser().parse(mapping);
|
||||
XContentDocumentMapper defaultMapper = MapperTests.newParser().parse(mapping);
|
||||
|
||||
ParsedDocument doc = defaultMapper.parse("type", "1", XContentFactory.jsonBuilder()
|
||||
.startObject()
|
||||
|
|
|
@ -23,8 +23,8 @@ import org.elasticsearch.common.Numbers;
|
|||
import org.elasticsearch.common.lucene.geo.GeoHashUtils;
|
||||
import org.elasticsearch.common.xcontent.XContentFactory;
|
||||
import org.elasticsearch.index.mapper.ParsedDocument;
|
||||
import org.elasticsearch.index.mapper.xcontent.MapperTests;
|
||||
import org.elasticsearch.index.mapper.xcontent.XContentDocumentMapper;
|
||||
import org.elasticsearch.index.mapper.xcontent.XContentMapperTests;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import static org.hamcrest.MatcherAssert.*;
|
||||
|
@ -40,7 +40,7 @@ public class LatLonMappingGeoPointTests {
|
|||
.startObject("properties").startObject("point").field("type", "geo_point").endObject().endObject()
|
||||
.endObject().endObject().string();
|
||||
|
||||
XContentDocumentMapper defaultMapper = XContentMapperTests.newParser().parse(mapping);
|
||||
XContentDocumentMapper defaultMapper = MapperTests.newParser().parse(mapping);
|
||||
|
||||
ParsedDocument doc = defaultMapper.parse("type", "1", XContentFactory.jsonBuilder()
|
||||
.startObject()
|
||||
|
@ -60,7 +60,7 @@ public class LatLonMappingGeoPointTests {
|
|||
.startObject("properties").startObject("point").field("type", "geo_point").field("store", "yes").endObject().endObject()
|
||||
.endObject().endObject().string();
|
||||
|
||||
XContentDocumentMapper defaultMapper = XContentMapperTests.newParser().parse(mapping);
|
||||
XContentDocumentMapper defaultMapper = MapperTests.newParser().parse(mapping);
|
||||
|
||||
ParsedDocument doc = defaultMapper.parse("type", "1", XContentFactory.jsonBuilder()
|
||||
.startObject()
|
||||
|
@ -80,7 +80,7 @@ public class LatLonMappingGeoPointTests {
|
|||
.startObject("properties").startObject("point").field("type", "geo_point").field("store", "yes").endObject().endObject()
|
||||
.endObject().endObject().string();
|
||||
|
||||
XContentDocumentMapper defaultMapper = XContentMapperTests.newParser().parse(mapping);
|
||||
XContentDocumentMapper defaultMapper = MapperTests.newParser().parse(mapping);
|
||||
|
||||
ParsedDocument doc = defaultMapper.parse("type", "1", XContentFactory.jsonBuilder()
|
||||
.startObject()
|
||||
|
@ -106,7 +106,7 @@ public class LatLonMappingGeoPointTests {
|
|||
.startObject("properties").startObject("point").field("type", "geo_point").endObject().endObject()
|
||||
.endObject().endObject().string();
|
||||
|
||||
XContentDocumentMapper defaultMapper = XContentMapperTests.newParser().parse(mapping);
|
||||
XContentDocumentMapper defaultMapper = MapperTests.newParser().parse(mapping);
|
||||
|
||||
ParsedDocument doc = defaultMapper.parse("type", "1", XContentFactory.jsonBuilder()
|
||||
.startObject()
|
||||
|
@ -124,7 +124,7 @@ public class LatLonMappingGeoPointTests {
|
|||
.startObject("properties").startObject("point").field("type", "geo_point").field("store", "yes").endObject().endObject()
|
||||
.endObject().endObject().string();
|
||||
|
||||
XContentDocumentMapper defaultMapper = XContentMapperTests.newParser().parse(mapping);
|
||||
XContentDocumentMapper defaultMapper = MapperTests.newParser().parse(mapping);
|
||||
|
||||
ParsedDocument doc = defaultMapper.parse("type", "1", XContentFactory.jsonBuilder()
|
||||
.startObject()
|
||||
|
@ -144,7 +144,7 @@ public class LatLonMappingGeoPointTests {
|
|||
.startObject("properties").startObject("point").field("type", "geo_point").field("store", "yes").endObject().endObject()
|
||||
.endObject().endObject().string();
|
||||
|
||||
XContentDocumentMapper defaultMapper = XContentMapperTests.newParser().parse(mapping);
|
||||
XContentDocumentMapper defaultMapper = MapperTests.newParser().parse(mapping);
|
||||
|
||||
ParsedDocument doc = defaultMapper.parse("type", "1", XContentFactory.jsonBuilder()
|
||||
.startObject()
|
||||
|
@ -170,7 +170,7 @@ public class LatLonMappingGeoPointTests {
|
|||
.startObject("properties").startObject("point").field("type", "geo_point").endObject().endObject()
|
||||
.endObject().endObject().string();
|
||||
|
||||
XContentDocumentMapper defaultMapper = XContentMapperTests.newParser().parse(mapping);
|
||||
XContentDocumentMapper defaultMapper = MapperTests.newParser().parse(mapping);
|
||||
|
||||
ParsedDocument doc = defaultMapper.parse("type", "1", XContentFactory.jsonBuilder()
|
||||
.startObject()
|
||||
|
@ -188,7 +188,7 @@ public class LatLonMappingGeoPointTests {
|
|||
.startObject("properties").startObject("point").field("type", "geo_point").endObject().endObject()
|
||||
.endObject().endObject().string();
|
||||
|
||||
XContentDocumentMapper defaultMapper = XContentMapperTests.newParser().parse(mapping);
|
||||
XContentDocumentMapper defaultMapper = MapperTests.newParser().parse(mapping);
|
||||
|
||||
ParsedDocument doc = defaultMapper.parse("type", "1", XContentFactory.jsonBuilder()
|
||||
.startObject()
|
||||
|
@ -208,7 +208,7 @@ public class LatLonMappingGeoPointTests {
|
|||
.startObject("properties").startObject("point").field("type", "geo_point").field("store", "yes").endObject().endObject()
|
||||
.endObject().endObject().string();
|
||||
|
||||
XContentDocumentMapper defaultMapper = XContentMapperTests.newParser().parse(mapping);
|
||||
XContentDocumentMapper defaultMapper = MapperTests.newParser().parse(mapping);
|
||||
|
||||
ParsedDocument doc = defaultMapper.parse("type", "1", XContentFactory.jsonBuilder()
|
||||
.startObject()
|
||||
|
@ -228,7 +228,7 @@ public class LatLonMappingGeoPointTests {
|
|||
.startObject("properties").startObject("point").field("type", "geo_point").field("store", "yes").endObject().endObject()
|
||||
.endObject().endObject().string();
|
||||
|
||||
XContentDocumentMapper defaultMapper = XContentMapperTests.newParser().parse(mapping);
|
||||
XContentDocumentMapper defaultMapper = MapperTests.newParser().parse(mapping);
|
||||
|
||||
ParsedDocument doc = defaultMapper.parse("type", "1", XContentFactory.jsonBuilder()
|
||||
.startObject()
|
||||
|
|
|
@ -23,8 +23,8 @@ import org.apache.lucene.document.Field;
|
|||
import org.elasticsearch.common.xcontent.XContentFactory;
|
||||
import org.elasticsearch.index.mapper.IndexFieldMapper;
|
||||
import org.elasticsearch.index.mapper.ParsedDocument;
|
||||
import org.elasticsearch.index.mapper.xcontent.MapperTests;
|
||||
import org.elasticsearch.index.mapper.xcontent.XContentDocumentMapper;
|
||||
import org.elasticsearch.index.mapper.xcontent.XContentMapperTests;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import static org.hamcrest.MatcherAssert.*;
|
||||
|
@ -39,7 +39,7 @@ public class IndexTypeMapperTests {
|
|||
String mapping = XContentFactory.jsonBuilder().startObject().startObject("type")
|
||||
.startObject("_index").field("enabled", true).field("store", "yes").endObject()
|
||||
.endObject().endObject().string();
|
||||
XContentDocumentMapper docMapper = XContentMapperTests.newParser().parse(mapping);
|
||||
XContentDocumentMapper docMapper = MapperTests.newParser().parse(mapping);
|
||||
assertThat(docMapper.indexMapper().enabled(), equalTo(true));
|
||||
assertThat(docMapper.indexMapper().store(), equalTo(Field.Store.YES));
|
||||
assertThat(docMapper.mappers().indexName("_index").mapper(), instanceOf(IndexFieldMapper.class));
|
||||
|
@ -58,7 +58,7 @@ public class IndexTypeMapperTests {
|
|||
String mapping = XContentFactory.jsonBuilder().startObject().startObject("type")
|
||||
.startObject("_index").field("enabled", false).field("store", "yes").endObject()
|
||||
.endObject().endObject().string();
|
||||
XContentDocumentMapper docMapper = XContentMapperTests.newParser().parse(mapping);
|
||||
XContentDocumentMapper docMapper = MapperTests.newParser().parse(mapping);
|
||||
assertThat(docMapper.indexMapper().enabled(), equalTo(false));
|
||||
assertThat(docMapper.indexMapper().store(), equalTo(Field.Store.YES));
|
||||
|
||||
|
@ -75,7 +75,7 @@ public class IndexTypeMapperTests {
|
|||
@Test public void defaultDisabledIndexMapperTests() throws Exception {
|
||||
String mapping = XContentFactory.jsonBuilder().startObject().startObject("type")
|
||||
.endObject().endObject().string();
|
||||
XContentDocumentMapper docMapper = XContentMapperTests.newParser().parse(mapping);
|
||||
XContentDocumentMapper docMapper = MapperTests.newParser().parse(mapping);
|
||||
assertThat(docMapper.indexMapper().enabled(), equalTo(false));
|
||||
assertThat(docMapper.indexMapper().store(), equalTo(Field.Store.NO));
|
||||
|
||||
|
|
|
@ -20,8 +20,8 @@
|
|||
package org.elasticsearch.index.mapper.xcontent.merge.test1;
|
||||
|
||||
import org.elasticsearch.index.mapper.DocumentMapper;
|
||||
import org.elasticsearch.index.mapper.xcontent.MapperTests;
|
||||
import org.elasticsearch.index.mapper.xcontent.XContentDocumentMapper;
|
||||
import org.elasticsearch.index.mapper.xcontent.XContentMapperTests;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import static org.elasticsearch.common.io.Streams.*;
|
||||
|
@ -37,9 +37,9 @@ public class Test1MergeMapperTests {
|
|||
|
||||
@Test public void test1Merge() throws Exception {
|
||||
String stage1Mapping = copyToStringFromClasspath("/org/elasticsearch/index/mapper/xcontent/merge/test1/stage1.json");
|
||||
XContentDocumentMapper stage1 = XContentMapperTests.newParser().parse(stage1Mapping);
|
||||
XContentDocumentMapper stage1 = MapperTests.newParser().parse(stage1Mapping);
|
||||
String stage2Mapping = copyToStringFromClasspath("/org/elasticsearch/index/mapper/xcontent/merge/test1/stage2.json");
|
||||
XContentDocumentMapper stage2 = XContentMapperTests.newParser().parse(stage2Mapping);
|
||||
XContentDocumentMapper stage2 = MapperTests.newParser().parse(stage2Mapping);
|
||||
|
||||
DocumentMapper.MergeResult mergeResult = stage1.merge(stage2, mergeFlags().simulate(true));
|
||||
assertThat(mergeResult.hasConflicts(), equalTo(false));
|
||||
|
|
|
@ -21,9 +21,9 @@ package org.elasticsearch.index.mapper.xcontent.multifield;
|
|||
|
||||
import org.apache.lucene.document.Document;
|
||||
import org.apache.lucene.document.Field;
|
||||
import org.elasticsearch.index.mapper.xcontent.MapperTests;
|
||||
import org.elasticsearch.index.mapper.xcontent.XContentDocumentMapper;
|
||||
import org.elasticsearch.index.mapper.xcontent.XContentDocumentMapperParser;
|
||||
import org.elasticsearch.index.mapper.xcontent.XContentMapperTests;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import static org.elasticsearch.common.io.Streams.*;
|
||||
|
@ -35,11 +35,11 @@ import static org.hamcrest.Matchers.*;
|
|||
* @author kimchy (shay.banon)
|
||||
*/
|
||||
@Test
|
||||
public class XContentMultiFieldTests {
|
||||
public class MultiFieldTests {
|
||||
|
||||
@Test public void testMultiField() throws Exception {
|
||||
String mapping = copyToStringFromClasspath("/org/elasticsearch/index/mapper/xcontent/multifield/test-mapping.json");
|
||||
XContentDocumentMapper docMapper = XContentMapperTests.newParser().parse(mapping);
|
||||
XContentDocumentMapper docMapper = MapperTests.newParser().parse(mapping);
|
||||
byte[] json = copyToBytesFromClasspath("/org/elasticsearch/index/mapper/xcontent/multifield/test-data.json");
|
||||
Document doc = docMapper.parse(json).doc();
|
||||
|
||||
|
@ -70,7 +70,7 @@ public class XContentMultiFieldTests {
|
|||
}
|
||||
|
||||
@Test public void testBuildThenParse() throws Exception {
|
||||
XContentDocumentMapperParser mapperParser = XContentMapperTests.newParser();
|
||||
XContentDocumentMapperParser mapperParser = MapperTests.newParser();
|
||||
XContentDocumentMapper builderDocMapper = doc("test", object("person").add(
|
||||
multiField("name")
|
||||
.add(stringField("name").store(Field.Store.YES))
|
|
@ -22,9 +22,9 @@ package org.elasticsearch.index.mapper.xcontent.multifield.merge;
|
|||
import org.apache.lucene.document.Document;
|
||||
import org.apache.lucene.document.Field;
|
||||
import org.elasticsearch.index.mapper.DocumentMapper;
|
||||
import org.elasticsearch.index.mapper.xcontent.MapperTests;
|
||||
import org.elasticsearch.index.mapper.xcontent.XContentDocumentMapper;
|
||||
import org.elasticsearch.index.mapper.xcontent.XContentDocumentMapperParser;
|
||||
import org.elasticsearch.index.mapper.xcontent.XContentMapperTests;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
@ -42,7 +42,7 @@ public class JavaMultiFieldMergeTests {
|
|||
|
||||
@Test public void testMergeMultiField() throws Exception {
|
||||
String mapping = copyToStringFromClasspath("/org/elasticsearch/index/mapper/xcontent/multifield/merge/test-mapping1.json");
|
||||
XContentDocumentMapperParser parser = XContentMapperTests.newParser();
|
||||
XContentDocumentMapperParser parser = MapperTests.newParser();
|
||||
|
||||
XContentDocumentMapper docMapper = parser.parse(mapping);
|
||||
|
||||
|
|
|
@ -21,8 +21,8 @@ package org.elasticsearch.index.mapper.xcontent.object;
|
|||
|
||||
import org.elasticsearch.common.xcontent.XContentFactory;
|
||||
import org.elasticsearch.index.mapper.ParsedDocument;
|
||||
import org.elasticsearch.index.mapper.xcontent.MapperTests;
|
||||
import org.elasticsearch.index.mapper.xcontent.XContentDocumentMapper;
|
||||
import org.elasticsearch.index.mapper.xcontent.XContentMapperTests;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import java.io.IOException;
|
||||
|
@ -33,14 +33,14 @@ import static org.hamcrest.Matchers.*;
|
|||
/**
|
||||
* @author kimchy (shay.banon)
|
||||
*/
|
||||
public class XContentNullValueObjectMappingTests {
|
||||
public class NullValueObjectMappingTests {
|
||||
|
||||
@Test public void testNullValueObject() throws IOException {
|
||||
String mapping = XContentFactory.jsonBuilder().startObject().startObject("type")
|
||||
.startObject("properties").startObject("obj1").field("type", "object").endObject().endObject()
|
||||
.endObject().endObject().string();
|
||||
|
||||
XContentDocumentMapper defaultMapper = XContentMapperTests.newParser().parse(mapping);
|
||||
XContentDocumentMapper defaultMapper = MapperTests.newParser().parse(mapping);
|
||||
|
||||
ParsedDocument doc = defaultMapper.parse("type", "1", XContentFactory.jsonBuilder()
|
||||
.startObject()
|
|
@ -20,8 +20,8 @@
|
|||
package org.elasticsearch.index.mapper.xcontent.overridetype;
|
||||
|
||||
import org.elasticsearch.common.xcontent.XContentFactory;
|
||||
import org.elasticsearch.index.mapper.xcontent.MapperTests;
|
||||
import org.elasticsearch.index.mapper.xcontent.XContentDocumentMapper;
|
||||
import org.elasticsearch.index.mapper.xcontent.XContentMapperTests;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import static org.hamcrest.MatcherAssert.*;
|
||||
|
@ -37,11 +37,11 @@ public class OverrideTypeMappingTests {
|
|||
.startObject("_source").field("enabled", false).endObject()
|
||||
.endObject().endObject().string();
|
||||
|
||||
XContentDocumentMapper mapper = XContentMapperTests.newParser().parse("my_type", mapping);
|
||||
XContentDocumentMapper mapper = MapperTests.newParser().parse("my_type", mapping);
|
||||
assertThat(mapper.type(), equalTo("my_type"));
|
||||
assertThat(mapper.sourceMapper().enabled(), equalTo(false));
|
||||
|
||||
mapper = XContentMapperTests.newParser().parse(mapping);
|
||||
mapper = MapperTests.newParser().parse(mapping);
|
||||
assertThat(mapper.type(), equalTo("type"));
|
||||
assertThat(mapper.sourceMapper().enabled(), equalTo(false));
|
||||
}
|
||||
|
|
|
@ -19,8 +19,8 @@
|
|||
|
||||
package org.elasticsearch.index.mapper.xcontent.path;
|
||||
|
||||
import org.elasticsearch.index.mapper.xcontent.MapperTests;
|
||||
import org.elasticsearch.index.mapper.xcontent.XContentDocumentMapper;
|
||||
import org.elasticsearch.index.mapper.xcontent.XContentMapperTests;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import java.io.IOException;
|
||||
|
@ -32,11 +32,11 @@ import static org.hamcrest.Matchers.*;
|
|||
/**
|
||||
* @author kimchy (shay.banon)
|
||||
*/
|
||||
public class PathXContentMapperTests {
|
||||
public class PathMapperTests {
|
||||
|
||||
@Test public void testPathMapping() throws IOException {
|
||||
String mapping = copyToStringFromClasspath("/org/elasticsearch/index/mapper/xcontent/path/test-mapping.json");
|
||||
XContentDocumentMapper docMapper = XContentMapperTests.newParser().parse(mapping);
|
||||
XContentDocumentMapper docMapper = MapperTests.newParser().parse(mapping);
|
||||
|
||||
assertThat(docMapper.mappers().indexName("first1"), notNullValue());
|
||||
assertThat(docMapper.mappers().indexName("name1.first1"), nullValue());
|
|
@ -22,9 +22,9 @@ package org.elasticsearch.index.mapper.xcontent.simple;
|
|||
import org.apache.lucene.document.Document;
|
||||
import org.apache.lucene.document.Field;
|
||||
import org.elasticsearch.index.mapper.Uid;
|
||||
import org.elasticsearch.index.mapper.xcontent.MapperTests;
|
||||
import org.elasticsearch.index.mapper.xcontent.XContentDocumentMapper;
|
||||
import org.elasticsearch.index.mapper.xcontent.XContentDocumentMapperParser;
|
||||
import org.elasticsearch.index.mapper.xcontent.XContentMapperTests;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import static org.apache.lucene.document.Field.Store.*;
|
||||
|
@ -36,10 +36,10 @@ import static org.hamcrest.Matchers.*;
|
|||
/**
|
||||
* @author kimchy
|
||||
*/
|
||||
public class SimpleXContentMapperTests {
|
||||
public class SimpleMapperTests {
|
||||
|
||||
@Test public void testSimpleMapper() throws Exception {
|
||||
XContentDocumentMapperParser mapperParser = XContentMapperTests.newParser();
|
||||
XContentDocumentMapperParser mapperParser = MapperTests.newParser();
|
||||
XContentDocumentMapper docMapper = doc("test",
|
||||
object("person")
|
||||
.add(object("name").add(stringField("first").store(YES).index(Field.Index.NO)))
|
||||
|
@ -60,11 +60,11 @@ public class SimpleXContentMapperTests {
|
|||
|
||||
@Test public void testParseToJsonAndParse() throws Exception {
|
||||
String mapping = copyToStringFromClasspath("/org/elasticsearch/index/mapper/xcontent/simple/test-mapping.json");
|
||||
XContentDocumentMapper docMapper = XContentMapperTests.newParser().parse(mapping);
|
||||
XContentDocumentMapper docMapper = MapperTests.newParser().parse(mapping);
|
||||
String builtMapping = docMapper.mappingSource().string();
|
||||
// System.out.println(builtMapping);
|
||||
// reparse it
|
||||
XContentDocumentMapper builtDocMapper = XContentMapperTests.newParser().parse(builtMapping);
|
||||
XContentDocumentMapper builtDocMapper = MapperTests.newParser().parse(builtMapping);
|
||||
byte[] json = copyToBytesFromClasspath("/org/elasticsearch/index/mapper/xcontent/simple/test1.json");
|
||||
Document doc = builtDocMapper.parse(json).doc();
|
||||
assertThat(doc.get(docMapper.uidMapper().names().indexName()), equalTo(Uid.createUid("person", "1")));
|
||||
|
@ -77,7 +77,7 @@ public class SimpleXContentMapperTests {
|
|||
|
||||
@Test public void testSimpleParser() throws Exception {
|
||||
String mapping = copyToStringFromClasspath("/org/elasticsearch/index/mapper/xcontent/simple/test-mapping.json");
|
||||
XContentDocumentMapper docMapper = XContentMapperTests.newParser().parse(mapping);
|
||||
XContentDocumentMapper docMapper = MapperTests.newParser().parse(mapping);
|
||||
|
||||
assertThat((String) docMapper.attributes().get("param1"), equalTo("value1"));
|
||||
|
||||
|
@ -93,7 +93,7 @@ public class SimpleXContentMapperTests {
|
|||
|
||||
@Test public void testSimpleParserNoTypeNoId() throws Exception {
|
||||
String mapping = copyToStringFromClasspath("/org/elasticsearch/index/mapper/xcontent/simple/test-mapping.json");
|
||||
XContentDocumentMapper docMapper = XContentMapperTests.newParser().parse(mapping);
|
||||
XContentDocumentMapper docMapper = MapperTests.newParser().parse(mapping);
|
||||
byte[] json = copyToBytesFromClasspath("/org/elasticsearch/index/mapper/xcontent/simple/test1-notype-noid.json");
|
||||
Document doc = docMapper.parse("person", "1", json).doc();
|
||||
assertThat(doc.get(docMapper.uidMapper().names().indexName()), equalTo(Uid.createUid("person", "1")));
|
|
@ -21,8 +21,8 @@ package org.elasticsearch.index.mapper.xcontent.typelevels;
|
|||
|
||||
import org.elasticsearch.common.xcontent.XContentFactory;
|
||||
import org.elasticsearch.index.mapper.ParsedDocument;
|
||||
import org.elasticsearch.index.mapper.xcontent.MapperTests;
|
||||
import org.elasticsearch.index.mapper.xcontent.XContentDocumentMapper;
|
||||
import org.elasticsearch.index.mapper.xcontent.XContentMapperTests;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import static org.hamcrest.MatcherAssert.*;
|
||||
|
@ -36,7 +36,7 @@ public class ParseDocumentTypeLevelsTests {
|
|||
@Test public void testNoLevel() throws Exception {
|
||||
String defaultMapping = XContentFactory.jsonBuilder().startObject().startObject("type").endObject().endObject().string();
|
||||
|
||||
XContentDocumentMapper defaultMapper = XContentMapperTests.newParser().parse(defaultMapping);
|
||||
XContentDocumentMapper defaultMapper = MapperTests.newParser().parse(defaultMapping);
|
||||
|
||||
ParsedDocument doc = defaultMapper.parse("type", "1", XContentFactory.jsonBuilder()
|
||||
.startObject()
|
||||
|
@ -54,7 +54,7 @@ public class ParseDocumentTypeLevelsTests {
|
|||
@Test public void testTypeLevel() throws Exception {
|
||||
String defaultMapping = XContentFactory.jsonBuilder().startObject().startObject("type").endObject().endObject().string();
|
||||
|
||||
XContentDocumentMapper defaultMapper = XContentMapperTests.newParser().parse(defaultMapping);
|
||||
XContentDocumentMapper defaultMapper = MapperTests.newParser().parse(defaultMapping);
|
||||
|
||||
ParsedDocument doc = defaultMapper.parse("type", "1", XContentFactory.jsonBuilder()
|
||||
.startObject().startObject("type")
|
||||
|
@ -72,7 +72,7 @@ public class ParseDocumentTypeLevelsTests {
|
|||
@Test public void testNoLevelWithFieldTypeAsValue() throws Exception {
|
||||
String defaultMapping = XContentFactory.jsonBuilder().startObject().startObject("type").endObject().endObject().string();
|
||||
|
||||
XContentDocumentMapper defaultMapper = XContentMapperTests.newParser().parse(defaultMapping);
|
||||
XContentDocumentMapper defaultMapper = MapperTests.newParser().parse(defaultMapping);
|
||||
|
||||
ParsedDocument doc = defaultMapper.parse("type", "1", XContentFactory.jsonBuilder()
|
||||
.startObject()
|
||||
|
@ -92,7 +92,7 @@ public class ParseDocumentTypeLevelsTests {
|
|||
@Test public void testTypeLevelWithFieldTypeAsValue() throws Exception {
|
||||
String defaultMapping = XContentFactory.jsonBuilder().startObject().startObject("type").endObject().endObject().string();
|
||||
|
||||
XContentDocumentMapper defaultMapper = XContentMapperTests.newParser().parse(defaultMapping);
|
||||
XContentDocumentMapper defaultMapper = MapperTests.newParser().parse(defaultMapping);
|
||||
|
||||
ParsedDocument doc = defaultMapper.parse("type", "1", XContentFactory.jsonBuilder()
|
||||
.startObject().startObject("type")
|
||||
|
@ -112,7 +112,7 @@ public class ParseDocumentTypeLevelsTests {
|
|||
@Test public void testNoLevelWithFieldTypeAsObject() throws Exception {
|
||||
String defaultMapping = XContentFactory.jsonBuilder().startObject().startObject("type").endObject().endObject().string();
|
||||
|
||||
XContentDocumentMapper defaultMapper = XContentMapperTests.newParser().parse(defaultMapping);
|
||||
XContentDocumentMapper defaultMapper = MapperTests.newParser().parse(defaultMapping);
|
||||
|
||||
ParsedDocument doc = defaultMapper.parse("type", "1", XContentFactory.jsonBuilder()
|
||||
.startObject()
|
||||
|
@ -132,7 +132,7 @@ public class ParseDocumentTypeLevelsTests {
|
|||
@Test public void testTypeLevelWithFieldTypeAsObject() throws Exception {
|
||||
String defaultMapping = XContentFactory.jsonBuilder().startObject().startObject("type").endObject().endObject().string();
|
||||
|
||||
XContentDocumentMapper defaultMapper = XContentMapperTests.newParser().parse(defaultMapping);
|
||||
XContentDocumentMapper defaultMapper = MapperTests.newParser().parse(defaultMapping);
|
||||
|
||||
ParsedDocument doc = defaultMapper.parse("type", "1", XContentFactory.jsonBuilder()
|
||||
.startObject().startObject("type")
|
||||
|
@ -152,7 +152,7 @@ public class ParseDocumentTypeLevelsTests {
|
|||
@Test public void testNoLevelWithFieldTypeAsValueNotFirst() throws Exception {
|
||||
String defaultMapping = XContentFactory.jsonBuilder().startObject().startObject("type").endObject().endObject().string();
|
||||
|
||||
XContentDocumentMapper defaultMapper = XContentMapperTests.newParser().parse(defaultMapping);
|
||||
XContentDocumentMapper defaultMapper = MapperTests.newParser().parse(defaultMapping);
|
||||
|
||||
ParsedDocument doc = defaultMapper.parse("type", "1", XContentFactory.jsonBuilder()
|
||||
.startObject().startObject("type")
|
||||
|
@ -172,7 +172,7 @@ public class ParseDocumentTypeLevelsTests {
|
|||
@Test public void testTypeLevelWithFieldTypeAsValueNotFirst() throws Exception {
|
||||
String defaultMapping = XContentFactory.jsonBuilder().startObject().startObject("type").endObject().endObject().string();
|
||||
|
||||
XContentDocumentMapper defaultMapper = XContentMapperTests.newParser().parse(defaultMapping);
|
||||
XContentDocumentMapper defaultMapper = MapperTests.newParser().parse(defaultMapping);
|
||||
|
||||
ParsedDocument doc = defaultMapper.parse("type", "1", XContentFactory.jsonBuilder()
|
||||
.startObject().startObject("type")
|
||||
|
@ -192,7 +192,7 @@ public class ParseDocumentTypeLevelsTests {
|
|||
@Test public void testNoLevelWithFieldTypeAsObjectNotFirst() throws Exception {
|
||||
String defaultMapping = XContentFactory.jsonBuilder().startObject().startObject("type").endObject().endObject().string();
|
||||
|
||||
XContentDocumentMapper defaultMapper = XContentMapperTests.newParser().parse(defaultMapping);
|
||||
XContentDocumentMapper defaultMapper = MapperTests.newParser().parse(defaultMapping);
|
||||
|
||||
ParsedDocument doc = defaultMapper.parse("type", "1", XContentFactory.jsonBuilder()
|
||||
.startObject()
|
||||
|
@ -213,7 +213,7 @@ public class ParseDocumentTypeLevelsTests {
|
|||
@Test public void testTypeLevelWithFieldTypeAsObjectNotFirst() throws Exception {
|
||||
String defaultMapping = XContentFactory.jsonBuilder().startObject().startObject("type").endObject().endObject().string();
|
||||
|
||||
XContentDocumentMapper defaultMapper = XContentMapperTests.newParser().parse(defaultMapping);
|
||||
XContentDocumentMapper defaultMapper = MapperTests.newParser().parse(defaultMapping);
|
||||
|
||||
ParsedDocument doc = defaultMapper.parse("type", "1", XContentFactory.jsonBuilder()
|
||||
.startObject().startObject("type")
|
||||
|
|
|
@ -20,8 +20,8 @@
|
|||
package org.elasticsearch.index.mapper.xcontent.typelevels;
|
||||
|
||||
import org.elasticsearch.common.xcontent.XContentFactory;
|
||||
import org.elasticsearch.index.mapper.xcontent.MapperTests;
|
||||
import org.elasticsearch.index.mapper.xcontent.XContentDocumentMapper;
|
||||
import org.elasticsearch.index.mapper.xcontent.XContentMapperTests;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import static org.hamcrest.MatcherAssert.*;
|
||||
|
@ -37,11 +37,11 @@ public class ParseMappingTypeLevelTests {
|
|||
.startObject("_source").field("enabled", false).endObject()
|
||||
.endObject().endObject().string();
|
||||
|
||||
XContentDocumentMapper mapper = XContentMapperTests.newParser().parse("type", mapping);
|
||||
XContentDocumentMapper mapper = MapperTests.newParser().parse("type", mapping);
|
||||
assertThat(mapper.type(), equalTo("type"));
|
||||
assertThat(mapper.sourceMapper().enabled(), equalTo(false));
|
||||
|
||||
mapper = XContentMapperTests.newParser().parse(mapping);
|
||||
mapper = MapperTests.newParser().parse(mapping);
|
||||
assertThat(mapper.type(), equalTo("type"));
|
||||
assertThat(mapper.sourceMapper().enabled(), equalTo(false));
|
||||
}
|
||||
|
|
|
@ -52,7 +52,7 @@ import static org.elasticsearch.plugin.mapper.attachments.tika.TikaInstance.*;
|
|||
*
|
||||
* @author kimchy (shay.banon)
|
||||
*/
|
||||
public class XContentAttachmentMapper implements XContentMapper {
|
||||
public class AttachmentMapper implements XContentMapper {
|
||||
|
||||
public static final String CONTENT_TYPE = "attachment";
|
||||
|
||||
|
@ -60,19 +60,19 @@ public class XContentAttachmentMapper implements XContentMapper {
|
|||
public static final ContentPath.Type PATH_TYPE = ContentPath.Type.FULL;
|
||||
}
|
||||
|
||||
public static class Builder extends XContentMapper.Builder<Builder, XContentAttachmentMapper> {
|
||||
public static class Builder extends XContentMapper.Builder<Builder, AttachmentMapper> {
|
||||
|
||||
private ContentPath.Type pathType = Defaults.PATH_TYPE;
|
||||
|
||||
private XContentStringFieldMapper.Builder contentBuilder;
|
||||
private StringFieldMapper.Builder contentBuilder;
|
||||
|
||||
private XContentStringFieldMapper.Builder titleBuilder = stringField("title");
|
||||
private StringFieldMapper.Builder titleBuilder = stringField("title");
|
||||
|
||||
private XContentStringFieldMapper.Builder authorBuilder = stringField("author");
|
||||
private StringFieldMapper.Builder authorBuilder = stringField("author");
|
||||
|
||||
private XContentStringFieldMapper.Builder keywordsBuilder = stringField("keywords");
|
||||
private StringFieldMapper.Builder keywordsBuilder = stringField("keywords");
|
||||
|
||||
private XContentDateFieldMapper.Builder dateBuilder = dateField("date");
|
||||
private DateFieldMapper.Builder dateBuilder = dateField("date");
|
||||
|
||||
public Builder(String name) {
|
||||
super(name);
|
||||
|
@ -85,49 +85,49 @@ public class XContentAttachmentMapper implements XContentMapper {
|
|||
return this;
|
||||
}
|
||||
|
||||
public Builder content(XContentStringFieldMapper.Builder content) {
|
||||
public Builder content(StringFieldMapper.Builder content) {
|
||||
this.contentBuilder = content;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder date(XContentDateFieldMapper.Builder date) {
|
||||
public Builder date(DateFieldMapper.Builder date) {
|
||||
this.dateBuilder = date;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder author(XContentStringFieldMapper.Builder author) {
|
||||
public Builder author(StringFieldMapper.Builder author) {
|
||||
this.authorBuilder = author;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder title(XContentStringFieldMapper.Builder title) {
|
||||
public Builder title(StringFieldMapper.Builder title) {
|
||||
this.titleBuilder = title;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder keywords(XContentStringFieldMapper.Builder keywords) {
|
||||
public Builder keywords(StringFieldMapper.Builder keywords) {
|
||||
this.keywordsBuilder = keywords;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override public XContentAttachmentMapper build(BuilderContext context) {
|
||||
@Override public AttachmentMapper build(BuilderContext context) {
|
||||
ContentPath.Type origPathType = context.path().pathType();
|
||||
context.path().pathType(pathType);
|
||||
|
||||
// create the content mapper under the actual name
|
||||
XContentStringFieldMapper contentMapper = contentBuilder.build(context);
|
||||
StringFieldMapper contentMapper = contentBuilder.build(context);
|
||||
|
||||
// create the DC one under the name
|
||||
context.path().add(name);
|
||||
XContentDateFieldMapper dateMapper = dateBuilder.build(context);
|
||||
XContentStringFieldMapper authorMapper = authorBuilder.build(context);
|
||||
XContentStringFieldMapper titleMapper = titleBuilder.build(context);
|
||||
XContentStringFieldMapper keywordsMapper = keywordsBuilder.build(context);
|
||||
DateFieldMapper dateMapper = dateBuilder.build(context);
|
||||
StringFieldMapper authorMapper = authorBuilder.build(context);
|
||||
StringFieldMapper titleMapper = titleBuilder.build(context);
|
||||
StringFieldMapper keywordsMapper = keywordsBuilder.build(context);
|
||||
context.path().remove();
|
||||
|
||||
context.path().pathType(origPathType);
|
||||
|
||||
return new XContentAttachmentMapper(name, pathType, contentMapper, dateMapper, titleMapper, authorMapper, keywordsMapper);
|
||||
return new AttachmentMapper(name, pathType, contentMapper, dateMapper, titleMapper, authorMapper, keywordsMapper);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -149,10 +149,10 @@ public class XContentAttachmentMapper implements XContentMapper {
|
|||
*
|
||||
* @author kimchy (shay.banon)
|
||||
*/
|
||||
public static class TypeParser implements XContentTypeParser {
|
||||
public static class TypeParser implements XContentMapper.TypeParser {
|
||||
|
||||
@SuppressWarnings({"unchecked"}) @Override public XContentMapper.Builder parse(String name, Map<String, Object> node, ParserContext parserContext) throws MapperParsingException {
|
||||
XContentAttachmentMapper.Builder builder = new XContentAttachmentMapper.Builder(name);
|
||||
AttachmentMapper.Builder builder = new AttachmentMapper.Builder(name);
|
||||
|
||||
for (Map.Entry<String, Object> entry : node.entrySet()) {
|
||||
String fieldName = entry.getKey();
|
||||
|
@ -167,15 +167,15 @@ public class XContentAttachmentMapper implements XContentMapper {
|
|||
|
||||
if (name.equals(propName)) {
|
||||
// that is the content
|
||||
builder.content((XContentStringFieldMapper.Builder) parserContext.typeParser("string").parse(name, (Map<String, Object>) propNode, parserContext));
|
||||
builder.content((StringFieldMapper.Builder) parserContext.typeParser("string").parse(name, (Map<String, Object>) propNode, parserContext));
|
||||
} else if ("date".equals(propName)) {
|
||||
builder.date((XContentDateFieldMapper.Builder) parserContext.typeParser("date").parse("date", (Map<String, Object>) propNode, parserContext));
|
||||
builder.date((DateFieldMapper.Builder) parserContext.typeParser("date").parse("date", (Map<String, Object>) propNode, parserContext));
|
||||
} else if ("title".equals(propName)) {
|
||||
builder.title((XContentStringFieldMapper.Builder) parserContext.typeParser("string").parse("title", (Map<String, Object>) propNode, parserContext));
|
||||
builder.title((StringFieldMapper.Builder) parserContext.typeParser("string").parse("title", (Map<String, Object>) propNode, parserContext));
|
||||
} else if ("author".equals(propName)) {
|
||||
builder.author((XContentStringFieldMapper.Builder) parserContext.typeParser("string").parse("author", (Map<String, Object>) propNode, parserContext));
|
||||
builder.author((StringFieldMapper.Builder) parserContext.typeParser("string").parse("author", (Map<String, Object>) propNode, parserContext));
|
||||
} else if ("keywords".equals(propName)) {
|
||||
builder.keywords((XContentStringFieldMapper.Builder) parserContext.typeParser("string").parse("keywords", (Map<String, Object>) propNode, parserContext));
|
||||
builder.keywords((StringFieldMapper.Builder) parserContext.typeParser("string").parse("keywords", (Map<String, Object>) propNode, parserContext));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -189,19 +189,19 @@ public class XContentAttachmentMapper implements XContentMapper {
|
|||
|
||||
private final ContentPath.Type pathType;
|
||||
|
||||
private final XContentStringFieldMapper contentMapper;
|
||||
private final StringFieldMapper contentMapper;
|
||||
|
||||
private final XContentDateFieldMapper dateMapper;
|
||||
private final DateFieldMapper dateMapper;
|
||||
|
||||
private final XContentStringFieldMapper authorMapper;
|
||||
private final StringFieldMapper authorMapper;
|
||||
|
||||
private final XContentStringFieldMapper titleMapper;
|
||||
private final StringFieldMapper titleMapper;
|
||||
|
||||
private final XContentStringFieldMapper keywordsMapper;
|
||||
private final StringFieldMapper keywordsMapper;
|
||||
|
||||
public XContentAttachmentMapper(String name, ContentPath.Type pathType, XContentStringFieldMapper contentMapper,
|
||||
XContentDateFieldMapper dateMapper, XContentStringFieldMapper titleMapper, XContentStringFieldMapper authorMapper,
|
||||
XContentStringFieldMapper keywordsMapper) {
|
||||
public AttachmentMapper(String name, ContentPath.Type pathType, StringFieldMapper contentMapper,
|
||||
DateFieldMapper dateMapper, StringFieldMapper titleMapper, StringFieldMapper authorMapper,
|
||||
StringFieldMapper keywordsMapper) {
|
||||
this.name = name;
|
||||
this.pathType = pathType;
|
||||
this.contentMapper = contentMapper;
|
|
@ -29,11 +29,11 @@ import org.elasticsearch.index.settings.IndexSettings;
|
|||
/**
|
||||
* @author kimchy (shay.banon)
|
||||
*/
|
||||
public class XContentAttachmentMapperService extends AbstractIndexComponent {
|
||||
public class RegisterAttachmentType extends AbstractIndexComponent {
|
||||
|
||||
@Inject public XContentAttachmentMapperService(Index index, @IndexSettings Settings indexSettings, MapperService mapperService) {
|
||||
@Inject public RegisterAttachmentType(Index index, @IndexSettings Settings indexSettings, MapperService mapperService) {
|
||||
super(index, indexSettings);
|
||||
|
||||
((XContentDocumentMapperParser) mapperService.documentMapperParser()).putTypeParser("attachment", new XContentAttachmentMapper.TypeParser());
|
||||
((XContentDocumentMapperParser) mapperService.documentMapperParser()).putTypeParser("attachment", new AttachmentMapper.TypeParser());
|
||||
}
|
||||
}
|
|
@ -20,14 +20,14 @@
|
|||
package org.elasticsearch.plugin.mapper.attachments;
|
||||
|
||||
import org.elasticsearch.common.inject.AbstractModule;
|
||||
import org.elasticsearch.index.mapper.xcontent.XContentAttachmentMapperService;
|
||||
import org.elasticsearch.index.mapper.xcontent.RegisterAttachmentType;
|
||||
|
||||
/**
|
||||
* @author kimchy (shay.banon)
|
||||
*/
|
||||
public class MapperAttachmentsIndexModule extends AbstractModule {
|
||||
public class AttachmentsIndexModule extends AbstractModule {
|
||||
|
||||
@Override protected void configure() {
|
||||
bind(XContentAttachmentMapperService.class).asEagerSingleton();
|
||||
bind(RegisterAttachmentType.class).asEagerSingleton();
|
||||
}
|
||||
}
|
|
@ -41,7 +41,7 @@ public class MapperAttachmentsPlugin extends AbstractPlugin {
|
|||
|
||||
@Override public Collection<Class<? extends Module>> indexModules() {
|
||||
Collection<Class<? extends Module>> modules = newArrayList();
|
||||
modules.add(MapperAttachmentsIndexModule.class);
|
||||
modules.add(AttachmentsIndexModule.class);
|
||||
return modules;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -40,7 +40,7 @@ public class SimpleAttachmentMapperTests {
|
|||
|
||||
@BeforeTest public void setupMapperParser() {
|
||||
mapperParser = new XContentDocumentMapperParser(new Index("test"), new AnalysisService(new Index("test")));
|
||||
mapperParser.putTypeParser(XContentAttachmentMapper.CONTENT_TYPE, new XContentAttachmentMapper.TypeParser());
|
||||
mapperParser.putTypeParser(AttachmentMapper.CONTENT_TYPE, new AttachmentMapper.TypeParser());
|
||||
}
|
||||
|
||||
@Test public void testSimpleMappings() throws Exception {
|
||||
|
|
Loading…
Reference in New Issue