simplify toXContent generation of field mappers
This commit is contained in:
parent
f3dbe9224a
commit
1867ef5084
|
@ -125,7 +125,7 @@ public class UidField extends Field {
|
|||
}
|
||||
|
||||
public UidField(String name, String uid, long version) {
|
||||
super(name, UidFieldMapper.Defaults.UID_FIELD_TYPE);
|
||||
super(name, UidFieldMapper.Defaults.FIELD_TYPE);
|
||||
this.uid = uid;
|
||||
this.version = version;
|
||||
this.tokenStream = new UidPayloadTokenStream(this);
|
||||
|
|
|
@ -45,7 +45,7 @@ public class PerFieldMappingPostingFormatCodec extends Lucene40Codec {
|
|||
|
||||
@Override
|
||||
public PostingsFormat getPostingsFormatForField(String field) {
|
||||
PostingsFormatProvider postingsFormat = mapperService.indexName(field).mapper().postingFormatProvider();
|
||||
PostingsFormatProvider postingsFormat = mapperService.indexName(field).mapper().postingsFormatProvider();
|
||||
return postingsFormat != null ? postingsFormat.get() : defaultPostingFormat;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -154,7 +154,7 @@ public class DocumentMapper implements ToXContent {
|
|||
if (indexSettings != null) {
|
||||
String idIndexed = indexSettings.get("index.mapping._id.indexed");
|
||||
if (idIndexed != null && Booleans.parseBoolean(idIndexed, false)) {
|
||||
FieldType fieldType = new FieldType(IdFieldMapper.Defaults.ID_FIELD_TYPE);
|
||||
FieldType fieldType = new FieldType(IdFieldMapper.Defaults.FIELD_TYPE);
|
||||
fieldType.setTokenized(false);
|
||||
idFieldMapper = new IdFieldMapper(fieldType);
|
||||
}
|
||||
|
@ -495,7 +495,6 @@ public class DocumentMapper implements ToXContent {
|
|||
}
|
||||
|
||||
// fire up any new mappers if exists
|
||||
// we do it here so postParse can rely on having them as part of this doc mapper
|
||||
if (!context.newFieldMappers().mappers.isEmpty()) {
|
||||
addFieldMappers(context.newFieldMappers().mappers);
|
||||
}
|
||||
|
|
|
@ -230,6 +230,6 @@ public interface FieldMapper<T> {
|
|||
|
||||
FieldDataType fieldDataType();
|
||||
|
||||
PostingsFormatProvider postingFormatProvider();
|
||||
PostingsFormatProvider postingsFormatProvider();
|
||||
|
||||
}
|
||||
|
|
|
@ -308,6 +308,8 @@ public abstract class AbstractFieldMapper<T> implements FieldMapper<T>, Mapper {
|
|||
return this.names;
|
||||
}
|
||||
|
||||
public abstract FieldType defaultFieldType();
|
||||
|
||||
@Override
|
||||
public boolean stored() {
|
||||
return fieldType.stored();
|
||||
|
@ -589,7 +591,7 @@ public abstract class AbstractFieldMapper<T> implements FieldMapper<T>, Mapper {
|
|||
}
|
||||
|
||||
@Override
|
||||
public PostingsFormatProvider postingFormatProvider() {
|
||||
public PostingsFormatProvider postingsFormatProvider() {
|
||||
return postingsFormat;
|
||||
}
|
||||
|
||||
|
@ -601,6 +603,65 @@ public abstract class AbstractFieldMapper<T> implements FieldMapper<T>, Mapper {
|
|||
return builder;
|
||||
}
|
||||
|
||||
protected void doXContentBody(XContentBuilder builder) throws IOException {
|
||||
builder.field("type", contentType());
|
||||
if (!names.name().equals(names.indexNameClean())) {
|
||||
builder.field("index_name", names.indexNameClean());
|
||||
}
|
||||
|
||||
if (boost != 1.0f) {
|
||||
builder.field("boost", boost);
|
||||
}
|
||||
|
||||
FieldType defaultFieldType = defaultFieldType();
|
||||
if (indexed() != defaultFieldType.indexed() ||
|
||||
tokenized() != defaultFieldType.tokenized()) {
|
||||
builder.field("index", indexTokenizeOptionToString(indexed(), tokenized()));
|
||||
}
|
||||
if (stored() != defaultFieldType.stored()) {
|
||||
builder.field("store", stored());
|
||||
}
|
||||
if (storeTermVectors() != defaultFieldType.storeTermVectors()) {
|
||||
builder.field("store_term_vector", storeTermVectors());
|
||||
}
|
||||
if (storeTermVectorOffsets() != defaultFieldType.storeTermVectorOffsets()) {
|
||||
builder.field("store_term_vector_offsets", storeTermVectorOffsets());
|
||||
}
|
||||
if (storeTermVectorPositions() != defaultFieldType.storeTermVectorPositions()) {
|
||||
builder.field("store_term_vector_positions", storeTermVectorPositions());
|
||||
}
|
||||
if (storeTermVectorPayloads() != defaultFieldType.storeTermVectorPayloads()) {
|
||||
builder.field("store_term_vector_payloads", storeTermVectorPayloads());
|
||||
}
|
||||
if (omitNorms() != defaultFieldType.omitNorms()) {
|
||||
builder.field("omit_norms", omitNorms());
|
||||
}
|
||||
if (indexOptions() != defaultFieldType.indexOptions()) {
|
||||
builder.field("index_options", indexOptionToString(indexOptions()));
|
||||
}
|
||||
|
||||
if (indexAnalyzer != null && searchAnalyzer != null && indexAnalyzer.name().equals(searchAnalyzer.name()) && !indexAnalyzer.name().startsWith("_") && !indexAnalyzer.name().equals("default")) {
|
||||
// same analyzers, output it once
|
||||
builder.field("analyzer", indexAnalyzer.name());
|
||||
} else {
|
||||
if (indexAnalyzer != null && !indexAnalyzer.name().startsWith("_") && !indexAnalyzer.name().equals("default")) {
|
||||
builder.field("index_analyzer", indexAnalyzer.name());
|
||||
}
|
||||
if (searchAnalyzer != null && !searchAnalyzer.name().startsWith("_") && !searchAnalyzer.name().equals("default")) {
|
||||
builder.field("search_analyzer", searchAnalyzer.name());
|
||||
}
|
||||
}
|
||||
if (postingsFormat != null) {
|
||||
if (!postingsFormat.name().equals(defaultPostingFormat())) {
|
||||
builder.field("postings_format", postingsFormat.name());
|
||||
}
|
||||
}
|
||||
|
||||
if (similarity() != null) {
|
||||
builder.field("similarity", similarity().name());
|
||||
}
|
||||
}
|
||||
|
||||
protected static String indexOptionToString(IndexOptions indexOption) {
|
||||
switch (indexOption) {
|
||||
case DOCS_AND_FREQS:
|
||||
|
@ -624,31 +685,6 @@ public abstract class AbstractFieldMapper<T> implements FieldMapper<T>, Mapper {
|
|||
}
|
||||
}
|
||||
|
||||
protected void doXContentBody(XContentBuilder builder) throws IOException {
|
||||
builder.field("type", contentType());
|
||||
if (!names.name().equals(names.indexNameClean())) {
|
||||
builder.field("index_name", names.indexNameClean());
|
||||
}
|
||||
if (boost != 1.0f) {
|
||||
builder.field("boost", boost);
|
||||
}
|
||||
if (indexAnalyzer != null && searchAnalyzer != null && indexAnalyzer.name().equals(searchAnalyzer.name()) && !indexAnalyzer.name().startsWith("_") && !indexAnalyzer.name().equals("default")) {
|
||||
// same analyzers, output it once
|
||||
builder.field("analyzer", indexAnalyzer.name());
|
||||
} else {
|
||||
if (indexAnalyzer != null && !indexAnalyzer.name().startsWith("_") && !indexAnalyzer.name().equals("default")) {
|
||||
builder.field("index_analyzer", indexAnalyzer.name());
|
||||
}
|
||||
if (searchAnalyzer != null && !searchAnalyzer.name().startsWith("_") && !searchAnalyzer.name().equals("default")) {
|
||||
builder.field("search_analyzer", searchAnalyzer.name());
|
||||
}
|
||||
}
|
||||
if (postingsFormat != null) {
|
||||
if (!postingsFormat.name().equals(defaultPostingFormat())) {
|
||||
builder.field("postings_format", postingsFormat.name());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected abstract String contentType();
|
||||
|
||||
|
|
|
@ -50,11 +50,11 @@ public class BinaryFieldMapper extends AbstractFieldMapper<byte[]> {
|
|||
|
||||
public static class Defaults extends AbstractFieldMapper.Defaults {
|
||||
public static final long COMPRESS_THRESHOLD = -1;
|
||||
public static final FieldType BINARY_FIELD_TYPE = new FieldType(AbstractFieldMapper.Defaults.FIELD_TYPE);
|
||||
public static final FieldType FIELD_TYPE = new FieldType(AbstractFieldMapper.Defaults.FIELD_TYPE);
|
||||
|
||||
static {
|
||||
BINARY_FIELD_TYPE.setStored(false);
|
||||
BINARY_FIELD_TYPE.freeze();
|
||||
FIELD_TYPE.setStored(false);
|
||||
FIELD_TYPE.freeze();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -65,7 +65,7 @@ public class BinaryFieldMapper extends AbstractFieldMapper<byte[]> {
|
|||
private long compressThreshold = Defaults.COMPRESS_THRESHOLD;
|
||||
|
||||
public Builder(String name) {
|
||||
super(name, new FieldType(Defaults.BINARY_FIELD_TYPE));
|
||||
super(name, new FieldType(Defaults.FIELD_TYPE));
|
||||
builder = this;
|
||||
}
|
||||
|
||||
|
@ -124,6 +124,11 @@ public class BinaryFieldMapper extends AbstractFieldMapper<byte[]> {
|
|||
this.compressThreshold = compressThreshold;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FieldType defaultFieldType() {
|
||||
return Defaults.FIELD_TYPE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object valueForSearch(Object value) {
|
||||
return value(value);
|
||||
|
|
|
@ -51,11 +51,11 @@ public class BooleanFieldMapper extends AbstractFieldMapper<Boolean> {
|
|||
public static final String CONTENT_TYPE = "boolean";
|
||||
|
||||
public static class Defaults extends AbstractFieldMapper.Defaults {
|
||||
public static final FieldType BOOLEAN_FIELD_TYPE = new FieldType(AbstractFieldMapper.Defaults.FIELD_TYPE);
|
||||
public static final FieldType FIELD_TYPE = new FieldType(AbstractFieldMapper.Defaults.FIELD_TYPE);
|
||||
|
||||
static {
|
||||
BOOLEAN_FIELD_TYPE.setOmitNorms(true);
|
||||
BOOLEAN_FIELD_TYPE.freeze();
|
||||
FIELD_TYPE.setOmitNorms(true);
|
||||
FIELD_TYPE.freeze();
|
||||
}
|
||||
|
||||
public static final Boolean NULL_VALUE = null;
|
||||
|
@ -71,7 +71,7 @@ public class BooleanFieldMapper extends AbstractFieldMapper<Boolean> {
|
|||
private Boolean nullValue = Defaults.NULL_VALUE;
|
||||
|
||||
public Builder(String name) {
|
||||
super(name, new FieldType(Defaults.BOOLEAN_FIELD_TYPE));
|
||||
super(name, new FieldType(Defaults.FIELD_TYPE));
|
||||
this.builder = this;
|
||||
}
|
||||
|
||||
|
@ -154,6 +154,11 @@ public class BooleanFieldMapper extends AbstractFieldMapper<Boolean> {
|
|||
this.nullValue = nullValue;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FieldType defaultFieldType() {
|
||||
return Defaults.FIELD_TYPE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean useFieldQueryWithQueryString() {
|
||||
return true;
|
||||
|
@ -224,34 +229,6 @@ public class BooleanFieldMapper extends AbstractFieldMapper<Boolean> {
|
|||
@Override
|
||||
protected void doXContentBody(XContentBuilder builder) throws IOException {
|
||||
super.doXContentBody(builder);
|
||||
if (indexed() != Defaults.BOOLEAN_FIELD_TYPE.indexed() ||
|
||||
tokenized() != Defaults.BOOLEAN_FIELD_TYPE.tokenized()) {
|
||||
builder.field("index", indexTokenizeOptionToString(indexed(), tokenized()));
|
||||
}
|
||||
if (stored() != Defaults.BOOLEAN_FIELD_TYPE.stored()) {
|
||||
builder.field("store", stored());
|
||||
}
|
||||
if (storeTermVectors() != Defaults.BOOLEAN_FIELD_TYPE.storeTermVectors()) {
|
||||
builder.field("store_term_vector", storeTermVectors());
|
||||
}
|
||||
if (storeTermVectorOffsets() != Defaults.BOOLEAN_FIELD_TYPE.storeTermVectorOffsets()) {
|
||||
builder.field("store_term_vector_offsets", storeTermVectorOffsets());
|
||||
}
|
||||
if (storeTermVectorPositions() != Defaults.BOOLEAN_FIELD_TYPE.storeTermVectorPositions()) {
|
||||
builder.field("store_term_vector_positions", storeTermVectorPositions());
|
||||
}
|
||||
if (storeTermVectorPayloads() != Defaults.BOOLEAN_FIELD_TYPE.storeTermVectorPayloads()) {
|
||||
builder.field("store_term_vector_payloads", storeTermVectorPayloads());
|
||||
}
|
||||
if (omitNorms() != Defaults.BOOLEAN_FIELD_TYPE.omitNorms()) {
|
||||
builder.field("omit_norms", omitNorms());
|
||||
}
|
||||
if (indexOptions() != Defaults.BOOLEAN_FIELD_TYPE.indexOptions()) {
|
||||
builder.field("index_options", indexOptionToString(indexOptions()));
|
||||
}
|
||||
if (similarity() != null) {
|
||||
builder.field("similarity", similarity().name());
|
||||
}
|
||||
if (nullValue != null) {
|
||||
builder.field("null_value", nullValue);
|
||||
}
|
||||
|
|
|
@ -60,10 +60,10 @@ public class ByteFieldMapper extends NumberFieldMapper<Byte> {
|
|||
public static final String CONTENT_TYPE = "byte";
|
||||
|
||||
public static class Defaults extends NumberFieldMapper.Defaults {
|
||||
public static final FieldType BYTE_FIELD_TYPE = new FieldType(NumberFieldMapper.Defaults.NUMBER_FIELD_TYPE);
|
||||
public static final FieldType FIELD_TYPE = new FieldType(NumberFieldMapper.Defaults.FIELD_TYPE);
|
||||
|
||||
static {
|
||||
BYTE_FIELD_TYPE.freeze();
|
||||
FIELD_TYPE.freeze();
|
||||
}
|
||||
|
||||
public static final Byte NULL_VALUE = null;
|
||||
|
@ -74,7 +74,7 @@ public class ByteFieldMapper extends NumberFieldMapper<Byte> {
|
|||
protected Byte nullValue = Defaults.NULL_VALUE;
|
||||
|
||||
public Builder(String name) {
|
||||
super(name, new FieldType(Defaults.BYTE_FIELD_TYPE));
|
||||
super(name, new FieldType(Defaults.FIELD_TYPE));
|
||||
builder = this;
|
||||
}
|
||||
|
||||
|
@ -123,6 +123,11 @@ public class ByteFieldMapper extends NumberFieldMapper<Byte> {
|
|||
this.nullValueAsString = nullValue == null ? null : nullValue.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public FieldType defaultFieldType() {
|
||||
return Defaults.FIELD_TYPE;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int maxPrecisionStep() {
|
||||
return 32;
|
||||
|
@ -328,40 +333,12 @@ public class ByteFieldMapper extends NumberFieldMapper<Byte> {
|
|||
@Override
|
||||
protected void doXContentBody(XContentBuilder builder) throws IOException {
|
||||
super.doXContentBody(builder);
|
||||
if (indexed() != Defaults.BYTE_FIELD_TYPE.indexed() ||
|
||||
tokenized() != Defaults.BYTE_FIELD_TYPE.tokenized()) {
|
||||
builder.field("index", indexTokenizeOptionToString(indexed(), tokenized()));
|
||||
}
|
||||
if (stored() != Defaults.BYTE_FIELD_TYPE.stored()) {
|
||||
builder.field("store", stored());
|
||||
}
|
||||
if (storeTermVectors() != Defaults.BYTE_FIELD_TYPE.storeTermVectors()) {
|
||||
builder.field("store_term_vector", storeTermVectors());
|
||||
}
|
||||
if (storeTermVectorOffsets() != Defaults.BYTE_FIELD_TYPE.storeTermVectorOffsets()) {
|
||||
builder.field("store_term_vector_offsets", storeTermVectorOffsets());
|
||||
}
|
||||
if (storeTermVectorPositions() != Defaults.BYTE_FIELD_TYPE.storeTermVectorPositions()) {
|
||||
builder.field("store_term_vector_positions", storeTermVectorPositions());
|
||||
}
|
||||
if (storeTermVectorPayloads() != Defaults.BYTE_FIELD_TYPE.storeTermVectorPayloads()) {
|
||||
builder.field("store_term_vector_payloads", storeTermVectorPayloads());
|
||||
}
|
||||
if (omitNorms() != Defaults.BYTE_FIELD_TYPE.omitNorms()) {
|
||||
builder.field("omit_norms", omitNorms());
|
||||
}
|
||||
if (indexOptions() != Defaults.BYTE_FIELD_TYPE.indexOptions()) {
|
||||
builder.field("index_options", indexOptionToString(indexOptions()));
|
||||
}
|
||||
if (precisionStep != Defaults.PRECISION_STEP) {
|
||||
builder.field("precision_step", precisionStep);
|
||||
}
|
||||
if (fuzzyFactor != Defaults.FUZZY_FACTOR) {
|
||||
builder.field("fuzzy_factor", fuzzyFactor);
|
||||
}
|
||||
if (similarity() != null) {
|
||||
builder.field("similarity", similarity().name());
|
||||
}
|
||||
if (nullValue != null) {
|
||||
builder.field("null_value", nullValue);
|
||||
}
|
||||
|
|
|
@ -66,10 +66,10 @@ public class DateFieldMapper extends NumberFieldMapper<Long> {
|
|||
public static class Defaults extends NumberFieldMapper.Defaults {
|
||||
public static final FormatDateTimeFormatter DATE_TIME_FORMATTER = Joda.forPattern("dateOptionalTime");
|
||||
|
||||
public static final FieldType DATE_FIELD_TYPE = new FieldType(NumberFieldMapper.Defaults.NUMBER_FIELD_TYPE);
|
||||
public static final FieldType FIELD_TYPE = new FieldType(NumberFieldMapper.Defaults.FIELD_TYPE);
|
||||
|
||||
static {
|
||||
DATE_FIELD_TYPE.freeze();
|
||||
FIELD_TYPE.freeze();
|
||||
}
|
||||
|
||||
public static final String NULL_VALUE = null;
|
||||
|
@ -87,7 +87,7 @@ public class DateFieldMapper extends NumberFieldMapper<Long> {
|
|||
protected FormatDateTimeFormatter dateTimeFormatter = Defaults.DATE_TIME_FORMATTER;
|
||||
|
||||
public Builder(String name) {
|
||||
super(name, new FieldType(Defaults.DATE_FIELD_TYPE));
|
||||
super(name, new FieldType(Defaults.FIELD_TYPE));
|
||||
builder = this;
|
||||
}
|
||||
|
||||
|
@ -167,6 +167,11 @@ public class DateFieldMapper extends NumberFieldMapper<Long> {
|
|||
this.dateMathParser = new DateMathParser(dateTimeFormatter, timeUnit);
|
||||
}
|
||||
|
||||
@Override
|
||||
public FieldType defaultFieldType() {
|
||||
return Defaults.FIELD_TYPE;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected double parseFuzzyFactor(String fuzzyFactor) {
|
||||
if (fuzzyFactor == null) {
|
||||
|
@ -402,31 +407,6 @@ public class DateFieldMapper extends NumberFieldMapper<Long> {
|
|||
@Override
|
||||
protected void doXContentBody(XContentBuilder builder) throws IOException {
|
||||
super.doXContentBody(builder);
|
||||
if (indexed() != Defaults.DATE_FIELD_TYPE.indexed() ||
|
||||
tokenized() != Defaults.DATE_FIELD_TYPE.tokenized()) {
|
||||
builder.field("index", indexTokenizeOptionToString(indexed(), tokenized()));
|
||||
}
|
||||
if (stored() != Defaults.DATE_FIELD_TYPE.stored()) {
|
||||
builder.field("store", stored());
|
||||
}
|
||||
if (storeTermVectors() != Defaults.DATE_FIELD_TYPE.storeTermVectors()) {
|
||||
builder.field("store_term_vector", storeTermVectors());
|
||||
}
|
||||
if (storeTermVectorOffsets() != Defaults.DATE_FIELD_TYPE.storeTermVectorOffsets()) {
|
||||
builder.field("store_term_vector_offsets", storeTermVectorOffsets());
|
||||
}
|
||||
if (storeTermVectorPositions() != Defaults.DATE_FIELD_TYPE.storeTermVectorPositions()) {
|
||||
builder.field("store_term_vector_positions", storeTermVectorPositions());
|
||||
}
|
||||
if (storeTermVectorPayloads() != Defaults.DATE_FIELD_TYPE.storeTermVectorPayloads()) {
|
||||
builder.field("store_term_vector_payloads", storeTermVectorPayloads());
|
||||
}
|
||||
if (omitNorms() != Defaults.DATE_FIELD_TYPE.omitNorms()) {
|
||||
builder.field("omit_norms", omitNorms());
|
||||
}
|
||||
if (indexOptions() != Defaults.DATE_FIELD_TYPE.indexOptions()) {
|
||||
builder.field("index_options", indexOptionToString(indexOptions()));
|
||||
}
|
||||
if (precisionStep != Defaults.PRECISION_STEP) {
|
||||
builder.field("precision_step", precisionStep);
|
||||
}
|
||||
|
@ -434,9 +414,6 @@ public class DateFieldMapper extends NumberFieldMapper<Long> {
|
|||
builder.field("fuzzy_factor", fuzzyFactor);
|
||||
}
|
||||
builder.field("format", dateTimeFormatter.format());
|
||||
if (similarity() != null) {
|
||||
builder.field("similarity", similarity().name());
|
||||
}
|
||||
if (nullValue != null) {
|
||||
builder.field("null_value", nullValue);
|
||||
}
|
||||
|
|
|
@ -60,10 +60,10 @@ public class DoubleFieldMapper extends NumberFieldMapper<Double> {
|
|||
public static final String CONTENT_TYPE = "double";
|
||||
|
||||
public static class Defaults extends NumberFieldMapper.Defaults {
|
||||
public static final FieldType DOUBLE_FIELD_TYPE = new FieldType(NumberFieldMapper.Defaults.NUMBER_FIELD_TYPE);
|
||||
public static final FieldType FIELD_TYPE = new FieldType(NumberFieldMapper.Defaults.FIELD_TYPE);
|
||||
|
||||
static {
|
||||
DOUBLE_FIELD_TYPE.freeze();
|
||||
FIELD_TYPE.freeze();
|
||||
}
|
||||
|
||||
public static final Double NULL_VALUE = null;
|
||||
|
@ -74,7 +74,7 @@ public class DoubleFieldMapper extends NumberFieldMapper<Double> {
|
|||
protected Double nullValue = Defaults.NULL_VALUE;
|
||||
|
||||
public Builder(String name) {
|
||||
super(name, new FieldType(Defaults.DOUBLE_FIELD_TYPE));
|
||||
super(name, new FieldType(Defaults.FIELD_TYPE));
|
||||
builder = this;
|
||||
}
|
||||
|
||||
|
@ -126,6 +126,11 @@ public class DoubleFieldMapper extends NumberFieldMapper<Double> {
|
|||
this.nullValueAsString = nullValue == null ? null : nullValue.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public FieldType defaultFieldType() {
|
||||
return Defaults.FIELD_TYPE;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int maxPrecisionStep() {
|
||||
return 64;
|
||||
|
@ -331,40 +336,12 @@ public class DoubleFieldMapper extends NumberFieldMapper<Double> {
|
|||
@Override
|
||||
protected void doXContentBody(XContentBuilder builder) throws IOException {
|
||||
super.doXContentBody(builder);
|
||||
if (indexed() != Defaults.DOUBLE_FIELD_TYPE.indexed() ||
|
||||
tokenized() != Defaults.DOUBLE_FIELD_TYPE.tokenized()) {
|
||||
builder.field("index", indexTokenizeOptionToString(indexed(), tokenized()));
|
||||
}
|
||||
if (stored() != Defaults.DOUBLE_FIELD_TYPE.stored()) {
|
||||
builder.field("store", stored());
|
||||
}
|
||||
if (storeTermVectors() != Defaults.DOUBLE_FIELD_TYPE.storeTermVectors()) {
|
||||
builder.field("store_term_vector", storeTermVectors());
|
||||
}
|
||||
if (storeTermVectorOffsets() != Defaults.DOUBLE_FIELD_TYPE.storeTermVectorOffsets()) {
|
||||
builder.field("store_term_vector_offsets", storeTermVectorOffsets());
|
||||
}
|
||||
if (storeTermVectorPositions() != Defaults.DOUBLE_FIELD_TYPE.storeTermVectorPositions()) {
|
||||
builder.field("store_term_vector_positions", storeTermVectorPositions());
|
||||
}
|
||||
if (storeTermVectorPayloads() != Defaults.DOUBLE_FIELD_TYPE.storeTermVectorPayloads()) {
|
||||
builder.field("store_term_vector_payloads", storeTermVectorPayloads());
|
||||
}
|
||||
if (omitNorms() != Defaults.DOUBLE_FIELD_TYPE.omitNorms()) {
|
||||
builder.field("omit_norms", omitNorms());
|
||||
}
|
||||
if (indexOptions() != Defaults.DOUBLE_FIELD_TYPE.indexOptions()) {
|
||||
builder.field("index_options", indexOptionToString(indexOptions()));
|
||||
}
|
||||
if (precisionStep != Defaults.PRECISION_STEP) {
|
||||
builder.field("precision_step", precisionStep);
|
||||
}
|
||||
if (fuzzyFactor != Defaults.FUZZY_FACTOR) {
|
||||
builder.field("fuzzy_factor", fuzzyFactor);
|
||||
}
|
||||
if (similarity() != null) {
|
||||
builder.field("similarity", similarity().name());
|
||||
}
|
||||
if (nullValue != null) {
|
||||
builder.field("null_value", nullValue);
|
||||
}
|
||||
|
|
|
@ -61,10 +61,10 @@ public class FloatFieldMapper extends NumberFieldMapper<Float> {
|
|||
public static final String CONTENT_TYPE = "float";
|
||||
|
||||
public static class Defaults extends NumberFieldMapper.Defaults {
|
||||
public static final FieldType FLOAT_FIELD_TYPE = new FieldType(NumberFieldMapper.Defaults.NUMBER_FIELD_TYPE);
|
||||
public static final FieldType FIELD_TYPE = new FieldType(NumberFieldMapper.Defaults.FIELD_TYPE);
|
||||
|
||||
static {
|
||||
FLOAT_FIELD_TYPE.freeze();
|
||||
FIELD_TYPE.freeze();
|
||||
}
|
||||
|
||||
public static final Float NULL_VALUE = null;
|
||||
|
@ -75,7 +75,7 @@ public class FloatFieldMapper extends NumberFieldMapper<Float> {
|
|||
protected Float nullValue = Defaults.NULL_VALUE;
|
||||
|
||||
public Builder(String name) {
|
||||
super(name, new FieldType(Defaults.FLOAT_FIELD_TYPE));
|
||||
super(name, new FieldType(Defaults.FIELD_TYPE));
|
||||
builder = this;
|
||||
}
|
||||
|
||||
|
@ -124,6 +124,11 @@ public class FloatFieldMapper extends NumberFieldMapper<Float> {
|
|||
this.nullValueAsString = nullValue == null ? null : nullValue.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public FieldType defaultFieldType() {
|
||||
return Defaults.FIELD_TYPE;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int maxPrecisionStep() {
|
||||
return 32;
|
||||
|
@ -326,40 +331,12 @@ public class FloatFieldMapper extends NumberFieldMapper<Float> {
|
|||
@Override
|
||||
protected void doXContentBody(XContentBuilder builder) throws IOException {
|
||||
super.doXContentBody(builder);
|
||||
if (indexed() != Defaults.FLOAT_FIELD_TYPE.indexed() ||
|
||||
tokenized() != Defaults.FLOAT_FIELD_TYPE.tokenized()) {
|
||||
builder.field("index", indexTokenizeOptionToString(indexed(), tokenized()));
|
||||
}
|
||||
if (stored() != Defaults.FLOAT_FIELD_TYPE.stored()) {
|
||||
builder.field("store", stored());
|
||||
}
|
||||
if (storeTermVectors() != Defaults.FLOAT_FIELD_TYPE.storeTermVectors()) {
|
||||
builder.field("store_term_vector", storeTermVectors());
|
||||
}
|
||||
if (storeTermVectorOffsets() != Defaults.FLOAT_FIELD_TYPE.storeTermVectorOffsets()) {
|
||||
builder.field("store_term_vector_offsets", storeTermVectorOffsets());
|
||||
}
|
||||
if (storeTermVectorPositions() != Defaults.FLOAT_FIELD_TYPE.storeTermVectorPositions()) {
|
||||
builder.field("store_term_vector_positions", storeTermVectorPositions());
|
||||
}
|
||||
if (storeTermVectorPayloads() != Defaults.FLOAT_FIELD_TYPE.storeTermVectorPayloads()) {
|
||||
builder.field("store_term_vector_payloads", storeTermVectorPayloads());
|
||||
}
|
||||
if (omitNorms() != Defaults.FLOAT_FIELD_TYPE.omitNorms()) {
|
||||
builder.field("omit_norms", omitNorms());
|
||||
}
|
||||
if (indexOptions() != Defaults.FLOAT_FIELD_TYPE.indexOptions()) {
|
||||
builder.field("index_options", indexOptionToString(indexOptions()));
|
||||
}
|
||||
if (precisionStep != Defaults.PRECISION_STEP) {
|
||||
builder.field("precision_step", precisionStep);
|
||||
}
|
||||
if (fuzzyFactor != Defaults.FUZZY_FACTOR) {
|
||||
builder.field("fuzzy_factor", fuzzyFactor);
|
||||
}
|
||||
if (similarity() != null) {
|
||||
builder.field("similarity", similarity().name());
|
||||
}
|
||||
if (nullValue != null) {
|
||||
builder.field("null_value", nullValue);
|
||||
}
|
||||
|
|
|
@ -61,10 +61,10 @@ public class IntegerFieldMapper extends NumberFieldMapper<Integer> {
|
|||
public static final String CONTENT_TYPE = "integer";
|
||||
|
||||
public static class Defaults extends NumberFieldMapper.Defaults {
|
||||
public static final FieldType INTEGER_FIELD_TYPE = new FieldType(NumberFieldMapper.Defaults.NUMBER_FIELD_TYPE);
|
||||
public static final FieldType FIELD_TYPE = new FieldType(NumberFieldMapper.Defaults.FIELD_TYPE);
|
||||
|
||||
static {
|
||||
INTEGER_FIELD_TYPE.freeze();
|
||||
FIELD_TYPE.freeze();
|
||||
}
|
||||
|
||||
public static final Integer NULL_VALUE = null;
|
||||
|
@ -75,7 +75,7 @@ public class IntegerFieldMapper extends NumberFieldMapper<Integer> {
|
|||
protected Integer nullValue = Defaults.NULL_VALUE;
|
||||
|
||||
public Builder(String name) {
|
||||
super(name, new FieldType(Defaults.INTEGER_FIELD_TYPE));
|
||||
super(name, new FieldType(Defaults.FIELD_TYPE));
|
||||
builder = this;
|
||||
}
|
||||
|
||||
|
@ -126,6 +126,11 @@ public class IntegerFieldMapper extends NumberFieldMapper<Integer> {
|
|||
this.nullValueAsString = nullValue == null ? null : nullValue.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public FieldType defaultFieldType() {
|
||||
return Defaults.FIELD_TYPE;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int maxPrecisionStep() {
|
||||
return 32;
|
||||
|
@ -331,40 +336,12 @@ public class IntegerFieldMapper extends NumberFieldMapper<Integer> {
|
|||
@Override
|
||||
protected void doXContentBody(XContentBuilder builder) throws IOException {
|
||||
super.doXContentBody(builder);
|
||||
if (indexed() != Defaults.INTEGER_FIELD_TYPE.indexed() ||
|
||||
tokenized() != Defaults.INTEGER_FIELD_TYPE.tokenized()) {
|
||||
builder.field("index", indexTokenizeOptionToString(indexed(), tokenized()));
|
||||
}
|
||||
if (stored() != Defaults.INTEGER_FIELD_TYPE.stored()) {
|
||||
builder.field("store", stored());
|
||||
}
|
||||
if (storeTermVectors() != Defaults.INTEGER_FIELD_TYPE.storeTermVectors()) {
|
||||
builder.field("store_term_vector", storeTermVectors());
|
||||
}
|
||||
if (storeTermVectorOffsets() != Defaults.INTEGER_FIELD_TYPE.storeTermVectorOffsets()) {
|
||||
builder.field("store_term_vector_offsets", storeTermVectorOffsets());
|
||||
}
|
||||
if (storeTermVectorPositions() != Defaults.INTEGER_FIELD_TYPE.storeTermVectorPositions()) {
|
||||
builder.field("store_term_vector_positions", storeTermVectorPositions());
|
||||
}
|
||||
if (storeTermVectorPayloads() != Defaults.INTEGER_FIELD_TYPE.storeTermVectorPayloads()) {
|
||||
builder.field("store_term_vector_payloads", storeTermVectorPayloads());
|
||||
}
|
||||
if (omitNorms() != Defaults.INTEGER_FIELD_TYPE.omitNorms()) {
|
||||
builder.field("omit_norms", omitNorms());
|
||||
}
|
||||
if (indexOptions() != Defaults.INTEGER_FIELD_TYPE.indexOptions()) {
|
||||
builder.field("index_options", indexOptionToString(indexOptions()));
|
||||
}
|
||||
if (precisionStep != Defaults.PRECISION_STEP) {
|
||||
builder.field("precision_step", precisionStep);
|
||||
}
|
||||
if (fuzzyFactor != Defaults.FUZZY_FACTOR) {
|
||||
builder.field("fuzzy_factor", fuzzyFactor);
|
||||
}
|
||||
if (similarity() != null) {
|
||||
builder.field("similarity", similarity().name());
|
||||
}
|
||||
if (nullValue != null) {
|
||||
builder.field("null_value", nullValue);
|
||||
}
|
||||
|
|
|
@ -61,10 +61,10 @@ public class LongFieldMapper extends NumberFieldMapper<Long> {
|
|||
public static final String CONTENT_TYPE = "long";
|
||||
|
||||
public static class Defaults extends NumberFieldMapper.Defaults {
|
||||
public static final FieldType LONG_FIELD_TYPE = new FieldType(NumberFieldMapper.Defaults.NUMBER_FIELD_TYPE);
|
||||
public static final FieldType FIELD_TYPE = new FieldType(NumberFieldMapper.Defaults.FIELD_TYPE);
|
||||
|
||||
static {
|
||||
LONG_FIELD_TYPE.freeze();
|
||||
FIELD_TYPE.freeze();
|
||||
}
|
||||
|
||||
public static final Long NULL_VALUE = null;
|
||||
|
@ -75,7 +75,7 @@ public class LongFieldMapper extends NumberFieldMapper<Long> {
|
|||
protected Long nullValue = Defaults.NULL_VALUE;
|
||||
|
||||
public Builder(String name) {
|
||||
super(name, new FieldType(Defaults.LONG_FIELD_TYPE));
|
||||
super(name, new FieldType(Defaults.FIELD_TYPE));
|
||||
builder = this;
|
||||
}
|
||||
|
||||
|
@ -86,7 +86,7 @@ public class LongFieldMapper extends NumberFieldMapper<Long> {
|
|||
|
||||
@Override
|
||||
public LongFieldMapper build(BuilderContext context) {
|
||||
fieldType.setOmitNorms(fieldType.omitNorms() && boost != 1.0f);
|
||||
fieldType.setOmitNorms(fieldType.omitNorms() && boost == 1.0f);
|
||||
LongFieldMapper fieldMapper = new LongFieldMapper(buildNames(context),
|
||||
precisionStep, fuzzyFactor, boost, fieldType, nullValue,
|
||||
ignoreMalformed(context), provider, similarity);
|
||||
|
@ -126,6 +126,11 @@ public class LongFieldMapper extends NumberFieldMapper<Long> {
|
|||
this.nullValueAsString = nullValue == null ? null : nullValue.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public FieldType defaultFieldType() {
|
||||
return Defaults.FIELD_TYPE;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int maxPrecisionStep() {
|
||||
return 64;
|
||||
|
@ -330,40 +335,12 @@ public class LongFieldMapper extends NumberFieldMapper<Long> {
|
|||
@Override
|
||||
protected void doXContentBody(XContentBuilder builder) throws IOException {
|
||||
super.doXContentBody(builder);
|
||||
if (indexed() != Defaults.LONG_FIELD_TYPE.indexed() ||
|
||||
tokenized() != Defaults.LONG_FIELD_TYPE.tokenized()) {
|
||||
builder.field("index", indexTokenizeOptionToString(indexed(), tokenized()));
|
||||
}
|
||||
if (stored() != Defaults.LONG_FIELD_TYPE.stored()) {
|
||||
builder.field("store", stored());
|
||||
}
|
||||
if (storeTermVectors() != Defaults.LONG_FIELD_TYPE.storeTermVectors()) {
|
||||
builder.field("store_term_vector", storeTermVectors());
|
||||
}
|
||||
if (storeTermVectorOffsets() != Defaults.LONG_FIELD_TYPE.storeTermVectorOffsets()) {
|
||||
builder.field("store_term_vector_offsets", storeTermVectorOffsets());
|
||||
}
|
||||
if (storeTermVectorPositions() != Defaults.LONG_FIELD_TYPE.storeTermVectorPositions()) {
|
||||
builder.field("store_term_vector_positions", storeTermVectorPositions());
|
||||
}
|
||||
if (storeTermVectorPayloads() != Defaults.LONG_FIELD_TYPE.storeTermVectorPayloads()) {
|
||||
builder.field("store_term_vector_payloads", storeTermVectorPayloads());
|
||||
}
|
||||
if (omitNorms() != Defaults.LONG_FIELD_TYPE.omitNorms()) {
|
||||
builder.field("omit_norms", omitNorms());
|
||||
}
|
||||
if (indexOptions() != Defaults.LONG_FIELD_TYPE.indexOptions()) {
|
||||
builder.field("index_options", indexOptionToString(indexOptions()));
|
||||
}
|
||||
if (precisionStep != Defaults.PRECISION_STEP) {
|
||||
builder.field("precision_step", precisionStep);
|
||||
}
|
||||
if (fuzzyFactor != Defaults.FUZZY_FACTOR) {
|
||||
builder.field("fuzzy_factor", fuzzyFactor);
|
||||
}
|
||||
if (similarity() != null) {
|
||||
builder.field("similarity", similarity().name());
|
||||
}
|
||||
if (nullValue != null) {
|
||||
builder.field("null_value", nullValue);
|
||||
}
|
||||
|
|
|
@ -50,14 +50,14 @@ public abstract class NumberFieldMapper<T extends Number> extends AbstractFieldM
|
|||
public static class Defaults extends AbstractFieldMapper.Defaults {
|
||||
public static final int PRECISION_STEP = NumericUtils.PRECISION_STEP_DEFAULT;
|
||||
|
||||
public static final FieldType NUMBER_FIELD_TYPE = new FieldType(AbstractFieldMapper.Defaults.FIELD_TYPE);
|
||||
public static final FieldType FIELD_TYPE = new FieldType(AbstractFieldMapper.Defaults.FIELD_TYPE);
|
||||
|
||||
static {
|
||||
NUMBER_FIELD_TYPE.setTokenized(false);
|
||||
NUMBER_FIELD_TYPE.setOmitNorms(true);
|
||||
NUMBER_FIELD_TYPE.setIndexOptions(IndexOptions.DOCS_ONLY);
|
||||
NUMBER_FIELD_TYPE.setStoreTermVectors(false);
|
||||
NUMBER_FIELD_TYPE.freeze();
|
||||
FIELD_TYPE.setTokenized(false);
|
||||
FIELD_TYPE.setOmitNorms(true);
|
||||
FIELD_TYPE.setIndexOptions(IndexOptions.DOCS_ONLY);
|
||||
FIELD_TYPE.setStoreTermVectors(false);
|
||||
FIELD_TYPE.freeze();
|
||||
}
|
||||
|
||||
public static final String FUZZY_FACTOR = null;
|
||||
|
|
|
@ -61,10 +61,10 @@ public class ShortFieldMapper extends NumberFieldMapper<Short> {
|
|||
public static final String CONTENT_TYPE = "short";
|
||||
|
||||
public static class Defaults extends NumberFieldMapper.Defaults {
|
||||
public static final FieldType SHORT_FIELD_TYPE = new FieldType(NumberFieldMapper.Defaults.NUMBER_FIELD_TYPE);
|
||||
public static final FieldType FIELD_TYPE = new FieldType(NumberFieldMapper.Defaults.FIELD_TYPE);
|
||||
|
||||
static {
|
||||
SHORT_FIELD_TYPE.freeze();
|
||||
FIELD_TYPE.freeze();
|
||||
}
|
||||
|
||||
public static final Short NULL_VALUE = null;
|
||||
|
@ -75,7 +75,7 @@ public class ShortFieldMapper extends NumberFieldMapper<Short> {
|
|||
protected Short nullValue = Defaults.NULL_VALUE;
|
||||
|
||||
public Builder(String name) {
|
||||
super(name, new FieldType(Defaults.SHORT_FIELD_TYPE));
|
||||
super(name, new FieldType(Defaults.FIELD_TYPE));
|
||||
builder = this;
|
||||
}
|
||||
|
||||
|
@ -126,6 +126,11 @@ public class ShortFieldMapper extends NumberFieldMapper<Short> {
|
|||
this.nullValueAsString = nullValue == null ? null : nullValue.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public FieldType defaultFieldType() {
|
||||
return Defaults.FIELD_TYPE;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int maxPrecisionStep() {
|
||||
return 32;
|
||||
|
@ -330,40 +335,12 @@ public class ShortFieldMapper extends NumberFieldMapper<Short> {
|
|||
@Override
|
||||
protected void doXContentBody(XContentBuilder builder) throws IOException {
|
||||
super.doXContentBody(builder);
|
||||
if (indexed() != Defaults.SHORT_FIELD_TYPE.indexed() ||
|
||||
tokenized() != Defaults.SHORT_FIELD_TYPE.tokenized()) {
|
||||
builder.field("index", indexTokenizeOptionToString(indexed(), tokenized()));
|
||||
}
|
||||
if (stored() != Defaults.SHORT_FIELD_TYPE.stored()) {
|
||||
builder.field("store", stored());
|
||||
}
|
||||
if (storeTermVectors() != Defaults.SHORT_FIELD_TYPE.storeTermVectors()) {
|
||||
builder.field("store_term_vector", storeTermVectors());
|
||||
}
|
||||
if (storeTermVectorOffsets() != Defaults.SHORT_FIELD_TYPE.storeTermVectorOffsets()) {
|
||||
builder.field("store_term_vector_offsets", storeTermVectorOffsets());
|
||||
}
|
||||
if (storeTermVectorPositions() != Defaults.SHORT_FIELD_TYPE.storeTermVectorPositions()) {
|
||||
builder.field("store_term_vector_positions", storeTermVectorPositions());
|
||||
}
|
||||
if (storeTermVectorPayloads() != Defaults.SHORT_FIELD_TYPE.storeTermVectorPayloads()) {
|
||||
builder.field("store_term_vector_payloads", storeTermVectorPayloads());
|
||||
}
|
||||
if (omitNorms() != Defaults.SHORT_FIELD_TYPE.omitNorms()) {
|
||||
builder.field("omit_norms", omitNorms());
|
||||
}
|
||||
if (indexOptions() != Defaults.SHORT_FIELD_TYPE.indexOptions()) {
|
||||
builder.field("index_options", indexOptionToString(indexOptions()));
|
||||
}
|
||||
if (precisionStep != Defaults.PRECISION_STEP) {
|
||||
builder.field("precision_step", precisionStep);
|
||||
}
|
||||
if (fuzzyFactor != Defaults.FUZZY_FACTOR) {
|
||||
builder.field("fuzzy_factor", fuzzyFactor);
|
||||
}
|
||||
if (similarity() != null) {
|
||||
builder.field("similarity", similarity().name());
|
||||
}
|
||||
if (nullValue != null) {
|
||||
builder.field("null_value", nullValue);
|
||||
}
|
||||
|
|
|
@ -52,10 +52,10 @@ public class StringFieldMapper extends AbstractFieldMapper<String> implements Al
|
|||
public static final String CONTENT_TYPE = "string";
|
||||
|
||||
public static class Defaults extends AbstractFieldMapper.Defaults {
|
||||
public static final FieldType STRING_FIELD_TYPE = new FieldType(AbstractFieldMapper.Defaults.FIELD_TYPE);
|
||||
public static final FieldType FIELD_TYPE = new FieldType(AbstractFieldMapper.Defaults.FIELD_TYPE);
|
||||
|
||||
static {
|
||||
STRING_FIELD_TYPE.freeze();
|
||||
FIELD_TYPE.freeze();
|
||||
}
|
||||
|
||||
// NOTE, when adding defaults here, make sure you add them in the builder
|
||||
|
@ -75,7 +75,7 @@ public class StringFieldMapper extends AbstractFieldMapper<String> implements Al
|
|||
protected int ignoreAbove = Defaults.IGNORE_ABOVE;
|
||||
|
||||
public Builder(String name) {
|
||||
super(name, new FieldType(Defaults.STRING_FIELD_TYPE));
|
||||
super(name, new FieldType(Defaults.FIELD_TYPE));
|
||||
builder = this;
|
||||
}
|
||||
|
||||
|
@ -205,6 +205,11 @@ public class StringFieldMapper extends AbstractFieldMapper<String> implements Al
|
|||
this.ignoreAbove = ignoreAbove;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FieldType defaultFieldType() {
|
||||
return Defaults.FIELD_TYPE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void includeInAll(Boolean includeInAll) {
|
||||
if (includeInAll != null) {
|
||||
|
@ -318,31 +323,6 @@ public class StringFieldMapper extends AbstractFieldMapper<String> implements Al
|
|||
@Override
|
||||
protected void doXContentBody(XContentBuilder builder) throws IOException {
|
||||
super.doXContentBody(builder);
|
||||
if (indexed() != Defaults.STRING_FIELD_TYPE.indexed() ||
|
||||
tokenized() != Defaults.STRING_FIELD_TYPE.tokenized()) {
|
||||
builder.field("index", indexTokenizeOptionToString(indexed(), tokenized()));
|
||||
}
|
||||
if (stored() != Defaults.STRING_FIELD_TYPE.stored()) {
|
||||
builder.field("store", stored());
|
||||
}
|
||||
if (storeTermVectors() != Defaults.STRING_FIELD_TYPE.storeTermVectors()) {
|
||||
builder.field("store_term_vector", storeTermVectors());
|
||||
}
|
||||
if (storeTermVectorOffsets() != Defaults.STRING_FIELD_TYPE.storeTermVectorOffsets()) {
|
||||
builder.field("store_term_vector_offsets", storeTermVectorOffsets());
|
||||
}
|
||||
if (storeTermVectorPositions() != Defaults.STRING_FIELD_TYPE.storeTermVectorPositions()) {
|
||||
builder.field("store_term_vector_positions", storeTermVectorPositions());
|
||||
}
|
||||
if (storeTermVectorPayloads() != Defaults.STRING_FIELD_TYPE.storeTermVectorPayloads()) {
|
||||
builder.field("store_term_vector_payloads", storeTermVectorPayloads());
|
||||
}
|
||||
if (omitNorms() != Defaults.STRING_FIELD_TYPE.omitNorms()) {
|
||||
builder.field("omit_norms", omitNorms());
|
||||
}
|
||||
if (indexOptions() != Defaults.STRING_FIELD_TYPE.indexOptions()) {
|
||||
builder.field("index_options", indexOptionToString(indexOptions()));
|
||||
}
|
||||
if (nullValue != null) {
|
||||
builder.field("null_value", nullValue);
|
||||
}
|
||||
|
@ -355,9 +335,6 @@ public class StringFieldMapper extends AbstractFieldMapper<String> implements Al
|
|||
if (searchQuotedAnalyzer != null && searchAnalyzer != searchQuotedAnalyzer) {
|
||||
builder.field("search_quote_analyzer", searchQuotedAnalyzer.name());
|
||||
}
|
||||
if (similarity() != null) {
|
||||
builder.field("similarity", similarity().name());
|
||||
}
|
||||
if (ignoreAbove != Defaults.IGNORE_ABOVE) {
|
||||
builder.field("ignore_above", ignoreAbove);
|
||||
}
|
||||
|
|
|
@ -81,14 +81,14 @@ public class GeoPointFieldMapper implements Mapper, ArrayValueMapperParser {
|
|||
public static final boolean VALIDATE_LAT = true;
|
||||
public static final boolean VALIDATE_LON = true;
|
||||
|
||||
public static final FieldType GEO_STRING_FIELD_TYPE = new FieldType(StringFieldMapper.Defaults.STRING_FIELD_TYPE);
|
||||
public static final FieldType FIELD_TYPE = new FieldType(StringFieldMapper.Defaults.FIELD_TYPE);
|
||||
|
||||
static {
|
||||
GEO_STRING_FIELD_TYPE.setIndexed(true);
|
||||
GEO_STRING_FIELD_TYPE.setTokenized(false);
|
||||
GEO_STRING_FIELD_TYPE.setOmitNorms(true);
|
||||
GEO_STRING_FIELD_TYPE.setIndexOptions(IndexOptions.DOCS_ONLY);
|
||||
GEO_STRING_FIELD_TYPE.freeze();
|
||||
FIELD_TYPE.setIndexed(true);
|
||||
FIELD_TYPE.setTokenized(false);
|
||||
FIELD_TYPE.setOmitNorms(true);
|
||||
FIELD_TYPE.setIndexOptions(IndexOptions.DOCS_ONLY);
|
||||
FIELD_TYPE.freeze();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -543,7 +543,7 @@ public class GeoPointFieldMapper implements Mapper, ArrayValueMapperParser {
|
|||
protected String nullValue = Defaults.NULL_VALUE;
|
||||
|
||||
public Builder(String name) {
|
||||
super(name, new FieldType(GeoPointFieldMapper.Defaults.GEO_STRING_FIELD_TYPE));
|
||||
super(name, new FieldType(GeoPointFieldMapper.Defaults.FIELD_TYPE));
|
||||
builder = this;
|
||||
}
|
||||
|
||||
|
@ -575,6 +575,11 @@ public class GeoPointFieldMapper implements Mapper, ArrayValueMapperParser {
|
|||
super(names, boost, fieldType, nullValue, indexAnalyzer, searchAnalyzer, provider, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public FieldType defaultFieldType() {
|
||||
return GeoPointFieldMapper.Defaults.FIELD_TYPE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FieldDataType fieldDataType() {
|
||||
return GeoPointFieldDataType.TYPE;
|
||||
|
|
|
@ -57,16 +57,16 @@ public class GeoShapeFieldMapper extends AbstractFieldMapper<String> {
|
|||
public static final int QUADTREE_LEVELS = QuadPrefixTree.DEFAULT_MAX_LEVELS;
|
||||
public static final double DISTANCE_ERROR_PCT = 0.025d;
|
||||
|
||||
public static final FieldType GEO_SHAPE_FIELD_TYPE = new FieldType();
|
||||
public static final FieldType FIELD_TYPE = new FieldType();
|
||||
|
||||
static {
|
||||
GEO_SHAPE_FIELD_TYPE.setIndexed(true);
|
||||
GEO_SHAPE_FIELD_TYPE.setTokenized(false);
|
||||
GEO_SHAPE_FIELD_TYPE.setStored(false);
|
||||
GEO_SHAPE_FIELD_TYPE.setStoreTermVectors(false);
|
||||
GEO_SHAPE_FIELD_TYPE.setOmitNorms(true);
|
||||
GEO_SHAPE_FIELD_TYPE.setIndexOptions(FieldInfo.IndexOptions.DOCS_ONLY);
|
||||
GEO_SHAPE_FIELD_TYPE.freeze();
|
||||
FIELD_TYPE.setIndexed(true);
|
||||
FIELD_TYPE.setTokenized(false);
|
||||
FIELD_TYPE.setStored(false);
|
||||
FIELD_TYPE.setStoreTermVectors(false);
|
||||
FIELD_TYPE.setOmitNorms(true);
|
||||
FIELD_TYPE.setIndexOptions(FieldInfo.IndexOptions.DOCS_ONLY);
|
||||
FIELD_TYPE.freeze();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -79,7 +79,7 @@ public class GeoShapeFieldMapper extends AbstractFieldMapper<String> {
|
|||
private SpatialPrefixTree prefixTree;
|
||||
|
||||
public Builder(String name) {
|
||||
super(name, new FieldType(Defaults.GEO_SHAPE_FIELD_TYPE));
|
||||
super(name, new FieldType(Defaults.FIELD_TYPE));
|
||||
}
|
||||
|
||||
public Builder tree(String tree) {
|
||||
|
@ -142,6 +142,11 @@ public class GeoShapeFieldMapper extends AbstractFieldMapper<String> {
|
|||
this.spatialStrategy = new TermQueryPrefixTreeStrategy(names, prefixTree, distanceErrorPct);
|
||||
}
|
||||
|
||||
@Override
|
||||
public FieldType defaultFieldType() {
|
||||
return Defaults.FIELD_TYPE;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Field parseCreateField(ParseContext context) throws IOException {
|
||||
return spatialStrategy.createField(GeoJSONShapeParser.parse(context.parser()));
|
||||
|
|
|
@ -66,12 +66,12 @@ public class AllFieldMapper extends AbstractFieldMapper<Void> implements Interna
|
|||
public static final String INDEX_NAME = AllFieldMapper.NAME;
|
||||
public static final boolean ENABLED = true;
|
||||
|
||||
public static final FieldType ALL_FIELD_TYPE = new FieldType();
|
||||
public static final FieldType FIELD_TYPE = new FieldType();
|
||||
|
||||
static {
|
||||
ALL_FIELD_TYPE.setIndexed(true);
|
||||
ALL_FIELD_TYPE.setTokenized(true);
|
||||
ALL_FIELD_TYPE.freeze();
|
||||
FIELD_TYPE.setIndexed(true);
|
||||
FIELD_TYPE.setTokenized(true);
|
||||
FIELD_TYPE.freeze();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -83,7 +83,7 @@ public class AllFieldMapper extends AbstractFieldMapper<Void> implements Interna
|
|||
boolean autoBoost = false;
|
||||
|
||||
public Builder() {
|
||||
super(Defaults.NAME, new FieldType(Defaults.ALL_FIELD_TYPE));
|
||||
super(Defaults.NAME, new FieldType(Defaults.FIELD_TYPE));
|
||||
builder = this;
|
||||
indexName = Defaults.INDEX_NAME;
|
||||
}
|
||||
|
@ -131,7 +131,7 @@ public class AllFieldMapper extends AbstractFieldMapper<Void> implements Interna
|
|||
private volatile boolean autoBoost;
|
||||
|
||||
public AllFieldMapper() {
|
||||
this(Defaults.NAME, new FieldType(Defaults.ALL_FIELD_TYPE), null, null, Defaults.ENABLED, false, null, null);
|
||||
this(Defaults.NAME, new FieldType(Defaults.FIELD_TYPE), null, null, Defaults.ENABLED, false, null, null);
|
||||
}
|
||||
|
||||
protected AllFieldMapper(String name, FieldType fieldType, NamedAnalyzer indexAnalyzer, NamedAnalyzer searchAnalyzer,
|
||||
|
@ -146,6 +146,11 @@ public class AllFieldMapper extends AbstractFieldMapper<Void> implements Interna
|
|||
return this.enabled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FieldType defaultFieldType() {
|
||||
return Defaults.FIELD_TYPE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Query queryStringTermQuery(Term term) {
|
||||
if (!autoBoost) {
|
||||
|
@ -248,8 +253,8 @@ public class AllFieldMapper extends AbstractFieldMapper<Void> implements Interna
|
|||
@Override
|
||||
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
|
||||
// if all are defaults, no need to write it at all
|
||||
if (enabled == Defaults.ENABLED && stored() == Defaults.ALL_FIELD_TYPE.stored() &&
|
||||
storeTermVectors() == Defaults.ALL_FIELD_TYPE.storeTermVectors() &&
|
||||
if (enabled == Defaults.ENABLED && stored() == Defaults.FIELD_TYPE.stored() &&
|
||||
storeTermVectors() == Defaults.FIELD_TYPE.storeTermVectors() &&
|
||||
indexAnalyzer == null && searchAnalyzer == null) {
|
||||
return builder;
|
||||
}
|
||||
|
@ -260,19 +265,19 @@ public class AllFieldMapper extends AbstractFieldMapper<Void> implements Interna
|
|||
if (autoBoost != false) {
|
||||
builder.field("auto_boost", autoBoost);
|
||||
}
|
||||
if (stored() != Defaults.ALL_FIELD_TYPE.stored()) {
|
||||
if (stored() != Defaults.FIELD_TYPE.stored()) {
|
||||
builder.field("store", stored());
|
||||
}
|
||||
if (storeTermVectors() != Defaults.ALL_FIELD_TYPE.storeTermVectors()) {
|
||||
if (storeTermVectors() != Defaults.FIELD_TYPE.storeTermVectors()) {
|
||||
builder.field("store_term_vector", storeTermVectors());
|
||||
}
|
||||
if (storeTermVectorOffsets() != Defaults.ALL_FIELD_TYPE.storeTermVectorOffsets()) {
|
||||
if (storeTermVectorOffsets() != Defaults.FIELD_TYPE.storeTermVectorOffsets()) {
|
||||
builder.field("store_term_vector_offsets", storeTermVectorOffsets());
|
||||
}
|
||||
if (storeTermVectorPositions() != Defaults.ALL_FIELD_TYPE.storeTermVectorPositions()) {
|
||||
if (storeTermVectorPositions() != Defaults.FIELD_TYPE.storeTermVectorPositions()) {
|
||||
builder.field("store_term_vector_positions", storeTermVectorPositions());
|
||||
}
|
||||
if (storeTermVectorPayloads() != Defaults.ALL_FIELD_TYPE.storeTermVectorPayloads()) {
|
||||
if (storeTermVectorPayloads() != Defaults.FIELD_TYPE.storeTermVectorPayloads()) {
|
||||
builder.field("store_term_vector_payloads", storeTermVectorPayloads());
|
||||
}
|
||||
if (indexAnalyzer != null && searchAnalyzer != null && indexAnalyzer.name().equals(searchAnalyzer.name()) && !indexAnalyzer.name().startsWith("_")) {
|
||||
|
|
|
@ -61,11 +61,11 @@ public class BoostFieldMapper extends NumberFieldMapper<Float> implements Intern
|
|||
public static final String NAME = "_boost";
|
||||
public static final Float NULL_VALUE = null;
|
||||
|
||||
public static final FieldType BOOST_FIELD_TYPE = new FieldType(NumberFieldMapper.Defaults.NUMBER_FIELD_TYPE);
|
||||
public static final FieldType FIELD_TYPE = new FieldType(NumberFieldMapper.Defaults.FIELD_TYPE);
|
||||
|
||||
static {
|
||||
BOOST_FIELD_TYPE.setIndexed(false);
|
||||
BOOST_FIELD_TYPE.setStored(false);
|
||||
FIELD_TYPE.setIndexed(false);
|
||||
FIELD_TYPE.setStored(false);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -74,7 +74,7 @@ public class BoostFieldMapper extends NumberFieldMapper<Float> implements Intern
|
|||
protected Float nullValue = Defaults.NULL_VALUE;
|
||||
|
||||
public Builder(String name) {
|
||||
super(name, new FieldType(Defaults.BOOST_FIELD_TYPE));
|
||||
super(name, new FieldType(Defaults.FIELD_TYPE));
|
||||
builder = this;
|
||||
}
|
||||
|
||||
|
@ -114,7 +114,7 @@ public class BoostFieldMapper extends NumberFieldMapper<Float> implements Intern
|
|||
}
|
||||
|
||||
protected BoostFieldMapper(String name, String indexName) {
|
||||
this(name, indexName, Defaults.PRECISION_STEP, Defaults.BOOST, new FieldType(Defaults.BOOST_FIELD_TYPE),
|
||||
this(name, indexName, Defaults.PRECISION_STEP, Defaults.BOOST, new FieldType(Defaults.FIELD_TYPE),
|
||||
Defaults.NULL_VALUE, null);
|
||||
}
|
||||
|
||||
|
@ -126,6 +126,11 @@ public class BoostFieldMapper extends NumberFieldMapper<Float> implements Intern
|
|||
this.nullValue = nullValue;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FieldType defaultFieldType() {
|
||||
return Defaults.FIELD_TYPE;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int maxPrecisionStep() {
|
||||
return 32;
|
||||
|
|
|
@ -59,14 +59,14 @@ public class IdFieldMapper extends AbstractFieldMapper<String> implements Intern
|
|||
public static final String NAME = IdFieldMapper.NAME;
|
||||
public static final String INDEX_NAME = IdFieldMapper.NAME;
|
||||
|
||||
public static final FieldType ID_FIELD_TYPE = new FieldType(AbstractFieldMapper.Defaults.FIELD_TYPE);
|
||||
public static final FieldType FIELD_TYPE = new FieldType(AbstractFieldMapper.Defaults.FIELD_TYPE);
|
||||
|
||||
static {
|
||||
ID_FIELD_TYPE.setIndexed(false);
|
||||
ID_FIELD_TYPE.setStored(false);
|
||||
ID_FIELD_TYPE.setOmitNorms(true);
|
||||
ID_FIELD_TYPE.setIndexOptions(IndexOptions.DOCS_ONLY);
|
||||
ID_FIELD_TYPE.freeze();
|
||||
FIELD_TYPE.setIndexed(false);
|
||||
FIELD_TYPE.setStored(false);
|
||||
FIELD_TYPE.setOmitNorms(true);
|
||||
FIELD_TYPE.setIndexOptions(IndexOptions.DOCS_ONLY);
|
||||
FIELD_TYPE.freeze();
|
||||
}
|
||||
|
||||
public static final String PATH = null;
|
||||
|
@ -77,7 +77,7 @@ public class IdFieldMapper extends AbstractFieldMapper<String> implements Intern
|
|||
private String path = Defaults.PATH;
|
||||
|
||||
public Builder() {
|
||||
super(Defaults.NAME, new FieldType(Defaults.ID_FIELD_TYPE));
|
||||
super(Defaults.NAME, new FieldType(Defaults.FIELD_TYPE));
|
||||
indexName = Defaults.INDEX_NAME;
|
||||
}
|
||||
|
||||
|
@ -111,7 +111,7 @@ public class IdFieldMapper extends AbstractFieldMapper<String> implements Intern
|
|||
private final String path;
|
||||
|
||||
public IdFieldMapper() {
|
||||
this(Defaults.NAME, Defaults.INDEX_NAME, new FieldType(Defaults.ID_FIELD_TYPE));
|
||||
this(Defaults.NAME, Defaults.INDEX_NAME, new FieldType(Defaults.FIELD_TYPE));
|
||||
}
|
||||
|
||||
public IdFieldMapper(FieldType fieldType) {
|
||||
|
@ -133,6 +133,11 @@ public class IdFieldMapper extends AbstractFieldMapper<String> implements Intern
|
|||
return this.path;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FieldType defaultFieldType() {
|
||||
return Defaults.FIELD_TYPE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String value(Object value) {
|
||||
return String.valueOf(value);
|
||||
|
@ -306,15 +311,15 @@ public class IdFieldMapper extends AbstractFieldMapper<String> implements Intern
|
|||
@Override
|
||||
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
|
||||
// if all are defaults, no sense to write it at all
|
||||
if (fieldType.stored() == Defaults.ID_FIELD_TYPE.stored() &&
|
||||
fieldType.indexed() == Defaults.ID_FIELD_TYPE.indexed() && path == Defaults.PATH) {
|
||||
if (fieldType.stored() == Defaults.FIELD_TYPE.stored() &&
|
||||
fieldType.indexed() == Defaults.FIELD_TYPE.indexed() && path == Defaults.PATH) {
|
||||
return builder;
|
||||
}
|
||||
builder.startObject(CONTENT_TYPE);
|
||||
if (fieldType.stored() != Defaults.ID_FIELD_TYPE.stored()) {
|
||||
if (fieldType.stored() != Defaults.FIELD_TYPE.stored()) {
|
||||
builder.field("store", fieldType.stored());
|
||||
}
|
||||
if (fieldType.indexed() != Defaults.ID_FIELD_TYPE.indexed()) {
|
||||
if (fieldType.indexed() != Defaults.FIELD_TYPE.indexed()) {
|
||||
builder.field("index", fieldType.indexed());
|
||||
}
|
||||
if (path != Defaults.PATH) {
|
||||
|
|
|
@ -50,15 +50,15 @@ public class IndexFieldMapper extends AbstractFieldMapper<String> implements Int
|
|||
public static final String NAME = IndexFieldMapper.NAME;
|
||||
public static final String INDEX_NAME = IndexFieldMapper.NAME;
|
||||
|
||||
public static final FieldType INDEX_FIELD_TYPE = new FieldType(AbstractFieldMapper.Defaults.FIELD_TYPE);
|
||||
public static final FieldType FIELD_TYPE = new FieldType(AbstractFieldMapper.Defaults.FIELD_TYPE);
|
||||
|
||||
static {
|
||||
INDEX_FIELD_TYPE.setIndexed(true);
|
||||
INDEX_FIELD_TYPE.setTokenized(false);
|
||||
INDEX_FIELD_TYPE.setStored(false);
|
||||
INDEX_FIELD_TYPE.setOmitNorms(true);
|
||||
INDEX_FIELD_TYPE.setIndexOptions(IndexOptions.DOCS_ONLY);
|
||||
INDEX_FIELD_TYPE.freeze();
|
||||
FIELD_TYPE.setIndexed(true);
|
||||
FIELD_TYPE.setTokenized(false);
|
||||
FIELD_TYPE.setStored(false);
|
||||
FIELD_TYPE.setOmitNorms(true);
|
||||
FIELD_TYPE.setIndexOptions(IndexOptions.DOCS_ONLY);
|
||||
FIELD_TYPE.freeze();
|
||||
}
|
||||
|
||||
public static final boolean ENABLED = false;
|
||||
|
@ -69,7 +69,7 @@ public class IndexFieldMapper extends AbstractFieldMapper<String> implements Int
|
|||
private boolean enabled = Defaults.ENABLED;
|
||||
|
||||
public Builder() {
|
||||
super(Defaults.NAME, new FieldType(Defaults.INDEX_FIELD_TYPE));
|
||||
super(Defaults.NAME, new FieldType(Defaults.FIELD_TYPE));
|
||||
indexName = Defaults.INDEX_NAME;
|
||||
}
|
||||
|
||||
|
@ -108,7 +108,7 @@ public class IndexFieldMapper extends AbstractFieldMapper<String> implements Int
|
|||
}
|
||||
|
||||
protected IndexFieldMapper(String name, String indexName) {
|
||||
this(name, indexName, Defaults.BOOST, new FieldType(Defaults.INDEX_FIELD_TYPE), Defaults.ENABLED, null);
|
||||
this(name, indexName, Defaults.BOOST, new FieldType(Defaults.FIELD_TYPE), Defaults.ENABLED, null);
|
||||
}
|
||||
|
||||
public IndexFieldMapper(String name, String indexName, float boost, FieldType fieldType, boolean enabled,
|
||||
|
@ -122,6 +122,11 @@ public class IndexFieldMapper extends AbstractFieldMapper<String> implements Int
|
|||
return this.enabled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FieldType defaultFieldType() {
|
||||
return Defaults.FIELD_TYPE;
|
||||
}
|
||||
|
||||
public String value(Document document) {
|
||||
Field field = (Field) document.getField(names.indexName());
|
||||
return field == null ? null : value(field);
|
||||
|
@ -181,11 +186,11 @@ public class IndexFieldMapper extends AbstractFieldMapper<String> implements Int
|
|||
@Override
|
||||
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
|
||||
// if all defaults, no need to write it at all
|
||||
if (stored() == Defaults.INDEX_FIELD_TYPE.stored() && enabled == Defaults.ENABLED) {
|
||||
if (stored() == Defaults.FIELD_TYPE.stored() && enabled == Defaults.ENABLED) {
|
||||
return builder;
|
||||
}
|
||||
builder.startObject(CONTENT_TYPE);
|
||||
if (stored() != Defaults.INDEX_FIELD_TYPE.stored()) {
|
||||
if (stored() != Defaults.FIELD_TYPE.stored()) {
|
||||
builder.field("store", stored());
|
||||
}
|
||||
if (enabled != Defaults.ENABLED) {
|
||||
|
|
|
@ -52,15 +52,15 @@ public class ParentFieldMapper extends AbstractFieldMapper<Uid> implements Inter
|
|||
public static class Defaults extends AbstractFieldMapper.Defaults {
|
||||
public static final String NAME = ParentFieldMapper.NAME;
|
||||
|
||||
public static final FieldType PARENT_FIELD_TYPE = new FieldType(AbstractFieldMapper.Defaults.FIELD_TYPE);
|
||||
public static final FieldType FIELD_TYPE = new FieldType(AbstractFieldMapper.Defaults.FIELD_TYPE);
|
||||
|
||||
static {
|
||||
PARENT_FIELD_TYPE.setIndexed(true);
|
||||
PARENT_FIELD_TYPE.setTokenized(false);
|
||||
PARENT_FIELD_TYPE.setStored(true);
|
||||
PARENT_FIELD_TYPE.setOmitNorms(true);
|
||||
PARENT_FIELD_TYPE.setIndexOptions(IndexOptions.DOCS_ONLY);
|
||||
PARENT_FIELD_TYPE.freeze();
|
||||
FIELD_TYPE.setIndexed(true);
|
||||
FIELD_TYPE.setTokenized(false);
|
||||
FIELD_TYPE.setStored(true);
|
||||
FIELD_TYPE.setOmitNorms(true);
|
||||
FIELD_TYPE.setIndexOptions(IndexOptions.DOCS_ONLY);
|
||||
FIELD_TYPE.freeze();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -116,7 +116,7 @@ public class ParentFieldMapper extends AbstractFieldMapper<Uid> implements Inter
|
|||
private final String type;
|
||||
|
||||
protected ParentFieldMapper(String name, String indexName, String type, PostingsFormatProvider postingsFormat) {
|
||||
super(new Names(name, indexName, indexName, name), Defaults.BOOST, new FieldType(Defaults.PARENT_FIELD_TYPE),
|
||||
super(new Names(name, indexName, indexName, name), Defaults.BOOST, new FieldType(Defaults.FIELD_TYPE),
|
||||
Lucene.KEYWORD_ANALYZER, Lucene.KEYWORD_ANALYZER, postingsFormat, null);
|
||||
this.type = type;
|
||||
}
|
||||
|
@ -125,6 +125,11 @@ public class ParentFieldMapper extends AbstractFieldMapper<Uid> implements Inter
|
|||
return type;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FieldType defaultFieldType() {
|
||||
return Defaults.FIELD_TYPE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void preParse(ParseContext context) throws IOException {
|
||||
}
|
||||
|
|
|
@ -49,15 +49,15 @@ public class RoutingFieldMapper extends AbstractFieldMapper<String> implements I
|
|||
public static class Defaults extends AbstractFieldMapper.Defaults {
|
||||
public static final String NAME = "_routing";
|
||||
|
||||
public static final FieldType ROUTING_FIELD_TYPE = new FieldType(AbstractFieldMapper.Defaults.FIELD_TYPE);
|
||||
public static final FieldType FIELD_TYPE = new FieldType(AbstractFieldMapper.Defaults.FIELD_TYPE);
|
||||
|
||||
static {
|
||||
ROUTING_FIELD_TYPE.setIndexed(true);
|
||||
ROUTING_FIELD_TYPE.setTokenized(false);
|
||||
ROUTING_FIELD_TYPE.setStored(true);
|
||||
ROUTING_FIELD_TYPE.setOmitNorms(true);
|
||||
ROUTING_FIELD_TYPE.setIndexOptions(IndexOptions.DOCS_ONLY);
|
||||
ROUTING_FIELD_TYPE.freeze();
|
||||
FIELD_TYPE.setIndexed(true);
|
||||
FIELD_TYPE.setTokenized(false);
|
||||
FIELD_TYPE.setStored(true);
|
||||
FIELD_TYPE.setOmitNorms(true);
|
||||
FIELD_TYPE.setIndexOptions(IndexOptions.DOCS_ONLY);
|
||||
FIELD_TYPE.freeze();
|
||||
}
|
||||
|
||||
public static final boolean REQUIRED = false;
|
||||
|
@ -71,7 +71,7 @@ public class RoutingFieldMapper extends AbstractFieldMapper<String> implements I
|
|||
private String path = Defaults.PATH;
|
||||
|
||||
public Builder() {
|
||||
super(Defaults.NAME, new FieldType(Defaults.ROUTING_FIELD_TYPE));
|
||||
super(Defaults.NAME, new FieldType(Defaults.FIELD_TYPE));
|
||||
}
|
||||
|
||||
public Builder required(boolean required) {
|
||||
|
@ -114,7 +114,7 @@ public class RoutingFieldMapper extends AbstractFieldMapper<String> implements I
|
|||
private final String path;
|
||||
|
||||
public RoutingFieldMapper() {
|
||||
this(new FieldType(Defaults.ROUTING_FIELD_TYPE), Defaults.REQUIRED, Defaults.PATH, null);
|
||||
this(new FieldType(Defaults.FIELD_TYPE), Defaults.REQUIRED, Defaults.PATH, null);
|
||||
}
|
||||
|
||||
protected RoutingFieldMapper(FieldType fieldType, boolean required, String path, PostingsFormatProvider provider) {
|
||||
|
@ -124,6 +124,11 @@ public class RoutingFieldMapper extends AbstractFieldMapper<String> implements I
|
|||
this.path = path;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FieldType defaultFieldType() {
|
||||
return Defaults.FIELD_TYPE;
|
||||
}
|
||||
|
||||
public void markAsRequired() {
|
||||
this.required = true;
|
||||
}
|
||||
|
@ -221,15 +226,15 @@ public class RoutingFieldMapper extends AbstractFieldMapper<String> implements I
|
|||
@Override
|
||||
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
|
||||
// if all are defaults, no sense to write it at all
|
||||
if (indexed() == Defaults.ROUTING_FIELD_TYPE.indexed() &&
|
||||
stored() == Defaults.ROUTING_FIELD_TYPE.stored() && required == Defaults.REQUIRED && path == Defaults.PATH) {
|
||||
if (indexed() == Defaults.FIELD_TYPE.indexed() &&
|
||||
stored() == Defaults.FIELD_TYPE.stored() && required == Defaults.REQUIRED && path == Defaults.PATH) {
|
||||
return builder;
|
||||
}
|
||||
builder.startObject(CONTENT_TYPE);
|
||||
if (indexed() != Defaults.ROUTING_FIELD_TYPE.indexed()) {
|
||||
if (indexed() != Defaults.FIELD_TYPE.indexed()) {
|
||||
builder.field("index", indexed());
|
||||
}
|
||||
if (stored() != Defaults.ROUTING_FIELD_TYPE.stored()) {
|
||||
if (stored() != Defaults.FIELD_TYPE.stored()) {
|
||||
builder.field("store", stored());
|
||||
}
|
||||
if (required != Defaults.REQUIRED) {
|
||||
|
|
|
@ -43,7 +43,7 @@ public class SizeFieldMapper extends IntegerFieldMapper implements RootMapper {
|
|||
public static final String NAME = CONTENT_TYPE;
|
||||
public static final boolean ENABLED = false;
|
||||
|
||||
public static final FieldType SIZE_FIELD_TYPE = new FieldType(IntegerFieldMapper.Defaults.INTEGER_FIELD_TYPE);
|
||||
public static final FieldType SIZE_FIELD_TYPE = new FieldType(IntegerFieldMapper.Defaults.FIELD_TYPE);
|
||||
|
||||
static {
|
||||
SIZE_FIELD_TYPE.freeze();
|
||||
|
|
|
@ -67,14 +67,14 @@ public class SourceFieldMapper extends AbstractFieldMapper<byte[]> implements In
|
|||
public static final long COMPRESS_THRESHOLD = -1;
|
||||
public static final String FORMAT = null; // default format is to use the one provided
|
||||
|
||||
public static final FieldType SOURCE_FIELD_TYPE = new FieldType(AbstractFieldMapper.Defaults.FIELD_TYPE);
|
||||
public static final FieldType FIELD_TYPE = new FieldType(AbstractFieldMapper.Defaults.FIELD_TYPE);
|
||||
|
||||
static {
|
||||
SOURCE_FIELD_TYPE.setIndexed(false);
|
||||
SOURCE_FIELD_TYPE.setStored(true);
|
||||
SOURCE_FIELD_TYPE.setOmitNorms(true);
|
||||
SOURCE_FIELD_TYPE.setIndexOptions(IndexOptions.DOCS_ONLY);
|
||||
SOURCE_FIELD_TYPE.freeze();
|
||||
FIELD_TYPE.setIndexed(false);
|
||||
FIELD_TYPE.setStored(true);
|
||||
FIELD_TYPE.setOmitNorms(true);
|
||||
FIELD_TYPE.setIndexOptions(IndexOptions.DOCS_ONLY);
|
||||
FIELD_TYPE.freeze();
|
||||
}
|
||||
|
||||
public static final String[] INCLUDES = Strings.EMPTY_ARRAY;
|
||||
|
@ -197,7 +197,7 @@ public class SourceFieldMapper extends AbstractFieldMapper<byte[]> implements In
|
|||
|
||||
protected SourceFieldMapper(String name, boolean enabled, String format, Boolean compress, long compressThreshold,
|
||||
String[] includes, String[] excludes) {
|
||||
super(new Names(name, name, name, name), Defaults.BOOST, new FieldType(Defaults.SOURCE_FIELD_TYPE),
|
||||
super(new Names(name, name, name, name), Defaults.BOOST, new FieldType(Defaults.FIELD_TYPE),
|
||||
Lucene.KEYWORD_ANALYZER, Lucene.KEYWORD_ANALYZER, null, null); // Only stored.
|
||||
this.enabled = enabled;
|
||||
this.compress = compress;
|
||||
|
@ -212,6 +212,11 @@ public class SourceFieldMapper extends AbstractFieldMapper<byte[]> implements In
|
|||
return this.enabled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FieldType defaultFieldType() {
|
||||
return Defaults.FIELD_TYPE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void preParse(ParseContext context) throws IOException {
|
||||
super.parse(context);
|
||||
|
|
|
@ -49,7 +49,7 @@ public class TTLFieldMapper extends LongFieldMapper implements InternalMapper, R
|
|||
public static class Defaults extends LongFieldMapper.Defaults {
|
||||
public static final String NAME = TTLFieldMapper.CONTENT_TYPE;
|
||||
|
||||
public static final FieldType TTL_FIELD_TYPE = new FieldType(LongFieldMapper.Defaults.LONG_FIELD_TYPE);
|
||||
public static final FieldType TTL_FIELD_TYPE = new FieldType(LongFieldMapper.Defaults.FIELD_TYPE);
|
||||
|
||||
static {
|
||||
TTL_FIELD_TYPE.setStored(true);
|
||||
|
|
|
@ -52,13 +52,13 @@ public class TimestampFieldMapper extends DateFieldMapper implements InternalMap
|
|||
public static class Defaults extends DateFieldMapper.Defaults {
|
||||
public static final String NAME = "_timestamp";
|
||||
|
||||
public static final FieldType TIMESTAMP_FIELD_TYPE = new FieldType(DateFieldMapper.Defaults.DATE_FIELD_TYPE);
|
||||
public static final FieldType FIELD_TYPE = new FieldType(DateFieldMapper.Defaults.FIELD_TYPE);
|
||||
|
||||
static {
|
||||
TIMESTAMP_FIELD_TYPE.setStored(false);
|
||||
TIMESTAMP_FIELD_TYPE.setIndexed(true);
|
||||
TIMESTAMP_FIELD_TYPE.setTokenized(false);
|
||||
TIMESTAMP_FIELD_TYPE.freeze();
|
||||
FIELD_TYPE.setStored(false);
|
||||
FIELD_TYPE.setIndexed(true);
|
||||
FIELD_TYPE.setTokenized(false);
|
||||
FIELD_TYPE.freeze();
|
||||
}
|
||||
|
||||
public static final boolean ENABLED = false;
|
||||
|
@ -73,7 +73,7 @@ public class TimestampFieldMapper extends DateFieldMapper implements InternalMap
|
|||
private FormatDateTimeFormatter dateTimeFormatter = Defaults.DATE_TIME_FORMATTER;
|
||||
|
||||
public Builder() {
|
||||
super(Defaults.NAME, new FieldType(Defaults.TIMESTAMP_FIELD_TYPE));
|
||||
super(Defaults.NAME, new FieldType(Defaults.FIELD_TYPE));
|
||||
}
|
||||
|
||||
public Builder enabled(boolean enabled) {
|
||||
|
@ -128,7 +128,7 @@ public class TimestampFieldMapper extends DateFieldMapper implements InternalMap
|
|||
private final String path;
|
||||
|
||||
public TimestampFieldMapper() {
|
||||
this(new FieldType(Defaults.TIMESTAMP_FIELD_TYPE), Defaults.ENABLED, Defaults.PATH, Defaults.DATE_TIME_FORMATTER,
|
||||
this(new FieldType(Defaults.FIELD_TYPE), Defaults.ENABLED, Defaults.PATH, Defaults.DATE_TIME_FORMATTER,
|
||||
Defaults.PARSE_UPPER_INCLUSIVE, Defaults.IGNORE_MALFORMED, null);
|
||||
}
|
||||
|
||||
|
@ -143,6 +143,11 @@ public class TimestampFieldMapper extends DateFieldMapper implements InternalMap
|
|||
this.path = path;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FieldType defaultFieldType() {
|
||||
return Defaults.FIELD_TYPE;
|
||||
}
|
||||
|
||||
public boolean enabled() {
|
||||
return this.enabled;
|
||||
}
|
||||
|
@ -218,16 +223,16 @@ public class TimestampFieldMapper extends DateFieldMapper implements InternalMap
|
|||
@Override
|
||||
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
|
||||
// if all are defaults, no sense to write it at all
|
||||
if (indexed() == Defaults.TIMESTAMP_FIELD_TYPE.indexed() &&
|
||||
stored() == Defaults.TIMESTAMP_FIELD_TYPE.stored() && enabled == Defaults.ENABLED && path == Defaults.PATH
|
||||
if (indexed() == Defaults.FIELD_TYPE.indexed() &&
|
||||
stored() == Defaults.FIELD_TYPE.stored() && enabled == Defaults.ENABLED && path == Defaults.PATH
|
||||
&& dateTimeFormatter.format().equals(Defaults.DATE_TIME_FORMATTER.format())) {
|
||||
return builder;
|
||||
}
|
||||
builder.startObject(CONTENT_TYPE);
|
||||
if (indexed() != Defaults.TIMESTAMP_FIELD_TYPE.indexed()) {
|
||||
if (indexed() != Defaults.FIELD_TYPE.indexed()) {
|
||||
builder.field("index", indexed());
|
||||
}
|
||||
if (stored() != Defaults.TIMESTAMP_FIELD_TYPE.stored()) {
|
||||
if (stored() != Defaults.FIELD_TYPE.stored()) {
|
||||
builder.field("store", stored());
|
||||
}
|
||||
if (enabled != Defaults.ENABLED) {
|
||||
|
|
|
@ -19,7 +19,6 @@
|
|||
|
||||
package org.elasticsearch.index.mapper.internal;
|
||||
|
||||
import org.apache.lucene.document.Document;
|
||||
import org.apache.lucene.document.Field;
|
||||
import org.apache.lucene.document.FieldType;
|
||||
import org.apache.lucene.index.FieldInfo.IndexOptions;
|
||||
|
@ -58,22 +57,22 @@ public class TypeFieldMapper extends AbstractFieldMapper<String> implements Inte
|
|||
public static final String NAME = TypeFieldMapper.NAME;
|
||||
public static final String INDEX_NAME = TypeFieldMapper.NAME;
|
||||
|
||||
public static final FieldType TYPE_FIELD_TYPE = new FieldType(AbstractFieldMapper.Defaults.FIELD_TYPE);
|
||||
public static final FieldType FIELD_TYPE = new FieldType(AbstractFieldMapper.Defaults.FIELD_TYPE);
|
||||
|
||||
static {
|
||||
TYPE_FIELD_TYPE.setIndexed(true);
|
||||
TYPE_FIELD_TYPE.setTokenized(false);
|
||||
TYPE_FIELD_TYPE.setStored(false);
|
||||
TYPE_FIELD_TYPE.setOmitNorms(true);
|
||||
TYPE_FIELD_TYPE.setIndexOptions(IndexOptions.DOCS_ONLY);
|
||||
TYPE_FIELD_TYPE.freeze();
|
||||
FIELD_TYPE.setIndexed(true);
|
||||
FIELD_TYPE.setTokenized(false);
|
||||
FIELD_TYPE.setStored(false);
|
||||
FIELD_TYPE.setOmitNorms(true);
|
||||
FIELD_TYPE.setIndexOptions(IndexOptions.DOCS_ONLY);
|
||||
FIELD_TYPE.freeze();
|
||||
}
|
||||
}
|
||||
|
||||
public static class Builder extends AbstractFieldMapper.Builder<Builder, TypeFieldMapper> {
|
||||
|
||||
public Builder() {
|
||||
super(Defaults.NAME, new FieldType(Defaults.TYPE_FIELD_TYPE));
|
||||
super(Defaults.NAME, new FieldType(Defaults.FIELD_TYPE));
|
||||
indexName = Defaults.INDEX_NAME;
|
||||
}
|
||||
|
||||
|
@ -98,7 +97,7 @@ public class TypeFieldMapper extends AbstractFieldMapper<String> implements Inte
|
|||
}
|
||||
|
||||
protected TypeFieldMapper(String name, String indexName) {
|
||||
this(name, indexName, Defaults.BOOST, new FieldType(Defaults.TYPE_FIELD_TYPE), null);
|
||||
this(name, indexName, Defaults.BOOST, new FieldType(Defaults.FIELD_TYPE), null);
|
||||
}
|
||||
|
||||
public TypeFieldMapper(String name, String indexName, float boost, FieldType fieldType, PostingsFormatProvider provider) {
|
||||
|
@ -106,9 +105,9 @@ public class TypeFieldMapper extends AbstractFieldMapper<String> implements Inte
|
|||
Lucene.KEYWORD_ANALYZER, provider, null);
|
||||
}
|
||||
|
||||
public String value(Document document) {
|
||||
Field field = (Field) document.getField(names.indexName());
|
||||
return field == null ? null : value(field);
|
||||
@Override
|
||||
public FieldType defaultFieldType() {
|
||||
return Defaults.FIELD_TYPE;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -182,14 +181,14 @@ public class TypeFieldMapper extends AbstractFieldMapper<String> implements Inte
|
|||
@Override
|
||||
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
|
||||
// if all are defaults, no sense to write it at all
|
||||
if (stored() == Defaults.TYPE_FIELD_TYPE.stored() && indexed() == Defaults.TYPE_FIELD_TYPE.indexed()) {
|
||||
if (stored() == Defaults.FIELD_TYPE.stored() && indexed() == Defaults.FIELD_TYPE.indexed()) {
|
||||
return builder;
|
||||
}
|
||||
builder.startObject(CONTENT_TYPE);
|
||||
if (stored() != Defaults.TYPE_FIELD_TYPE.stored()) {
|
||||
if (stored() != Defaults.FIELD_TYPE.stored()) {
|
||||
builder.field("store", stored());
|
||||
}
|
||||
if (indexed() != Defaults.TYPE_FIELD_TYPE.indexed()) {
|
||||
if (indexed() != Defaults.FIELD_TYPE.indexed()) {
|
||||
builder.field("index", indexed());
|
||||
}
|
||||
builder.endObject();
|
||||
|
|
|
@ -48,15 +48,15 @@ public class UidFieldMapper extends AbstractFieldMapper<Uid> implements Internal
|
|||
public static class Defaults extends AbstractFieldMapper.Defaults {
|
||||
public static final String NAME = UidFieldMapper.NAME;
|
||||
|
||||
public static final FieldType UID_FIELD_TYPE = new FieldType(AbstractFieldMapper.Defaults.FIELD_TYPE);
|
||||
public static final FieldType FIELD_TYPE = new FieldType(AbstractFieldMapper.Defaults.FIELD_TYPE);
|
||||
|
||||
static {
|
||||
UID_FIELD_TYPE.setIndexed(true);
|
||||
UID_FIELD_TYPE.setTokenized(false);
|
||||
UID_FIELD_TYPE.setStored(true);
|
||||
UID_FIELD_TYPE.setOmitNorms(true);
|
||||
UID_FIELD_TYPE.setIndexOptions(FieldInfo.IndexOptions.DOCS_AND_FREQS_AND_POSITIONS); // we store payload (otherwise, we really need just docs)
|
||||
UID_FIELD_TYPE.freeze();
|
||||
FIELD_TYPE.setIndexed(true);
|
||||
FIELD_TYPE.setTokenized(false);
|
||||
FIELD_TYPE.setStored(true);
|
||||
FIELD_TYPE.setOmitNorms(true);
|
||||
FIELD_TYPE.setIndexOptions(FieldInfo.IndexOptions.DOCS_AND_FREQS_AND_POSITIONS); // we store payload (otherwise, we really need just docs)
|
||||
FIELD_TYPE.freeze();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -108,10 +108,15 @@ public class UidFieldMapper extends AbstractFieldMapper<Uid> implements Internal
|
|||
}
|
||||
|
||||
protected UidFieldMapper(String name, String indexName, PostingsFormatProvider postingsFormat) {
|
||||
super(new Names(name, indexName, indexName, name), Defaults.BOOST, new FieldType(Defaults.UID_FIELD_TYPE),
|
||||
super(new Names(name, indexName, indexName, name), Defaults.BOOST, new FieldType(Defaults.FIELD_TYPE),
|
||||
Lucene.KEYWORD_ANALYZER, Lucene.KEYWORD_ANALYZER, postingsFormat, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public FieldType defaultFieldType() {
|
||||
return Defaults.FIELD_TYPE;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String defaultPostingFormat() {
|
||||
return "bloom_default";
|
||||
|
@ -204,12 +209,32 @@ public class UidFieldMapper extends AbstractFieldMapper<Uid> implements Internal
|
|||
|
||||
@Override
|
||||
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
|
||||
// for now, don't output it at all
|
||||
// if defaults, don't output
|
||||
if ((postingsFormat == null || postingsFormat.name().equals(defaultPostingFormat()))) {
|
||||
return builder;
|
||||
}
|
||||
|
||||
builder.startObject(CONTENT_TYPE);
|
||||
|
||||
if (postingsFormat != null) {
|
||||
if (!postingsFormat.name().equals(defaultPostingFormat())) {
|
||||
builder.field("postings_format", postingsFormat.name());
|
||||
}
|
||||
}
|
||||
|
||||
builder.endObject();
|
||||
return builder;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void merge(Mapper mergeWith, MergeContext mergeContext) throws MergeMappingException {
|
||||
AbstractFieldMapper fieldMergeWith = (AbstractFieldMapper) mergeWith;
|
||||
// do nothing here, no merging, but also no exception
|
||||
if (!mergeContext.mergeFlags().simulate()) {
|
||||
// apply changeable values
|
||||
if (fieldMergeWith.postingsFormatProvider() != null) {
|
||||
this.postingsFormat = fieldMergeWith.postingsFormatProvider();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -89,10 +89,10 @@ public class IpFieldMapper extends NumberFieldMapper<Long> {
|
|||
public static class Defaults extends NumberFieldMapper.Defaults {
|
||||
public static final String NULL_VALUE = null;
|
||||
|
||||
public static final FieldType IP_FIELD_TYPE = new FieldType(NumberFieldMapper.Defaults.NUMBER_FIELD_TYPE);
|
||||
public static final FieldType FIELD_TYPE = new FieldType(NumberFieldMapper.Defaults.FIELD_TYPE);
|
||||
|
||||
static {
|
||||
IP_FIELD_TYPE.freeze();
|
||||
FIELD_TYPE.freeze();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -101,7 +101,7 @@ public class IpFieldMapper extends NumberFieldMapper<Long> {
|
|||
protected String nullValue = Defaults.NULL_VALUE;
|
||||
|
||||
public Builder(String name) {
|
||||
super(name, new FieldType(Defaults.IP_FIELD_TYPE));
|
||||
super(name, new FieldType(Defaults.FIELD_TYPE));
|
||||
builder = this;
|
||||
}
|
||||
|
||||
|
@ -148,6 +148,11 @@ public class IpFieldMapper extends NumberFieldMapper<Long> {
|
|||
this.nullValue = nullValue;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FieldType defaultFieldType() {
|
||||
return Defaults.FIELD_TYPE;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int maxPrecisionStep() {
|
||||
return 64;
|
||||
|
@ -305,37 +310,9 @@ public class IpFieldMapper extends NumberFieldMapper<Long> {
|
|||
@Override
|
||||
protected void doXContentBody(XContentBuilder builder) throws IOException {
|
||||
super.doXContentBody(builder);
|
||||
if (indexed() != Defaults.IP_FIELD_TYPE.indexed() ||
|
||||
tokenized() != Defaults.IP_FIELD_TYPE.tokenized()) {
|
||||
builder.field("index", indexTokenizeOptionToString(indexed(), tokenized()));
|
||||
}
|
||||
if (stored() != Defaults.IP_FIELD_TYPE.stored()) {
|
||||
builder.field("store", stored());
|
||||
}
|
||||
if (storeTermVectors() != Defaults.IP_FIELD_TYPE.storeTermVectors()) {
|
||||
builder.field("store_term_vector", storeTermVectors());
|
||||
}
|
||||
if (storeTermVectorOffsets() != Defaults.IP_FIELD_TYPE.storeTermVectorOffsets()) {
|
||||
builder.field("store_term_vector_offsets", storeTermVectorOffsets());
|
||||
}
|
||||
if (storeTermVectorPositions() != Defaults.IP_FIELD_TYPE.storeTermVectorPositions()) {
|
||||
builder.field("store_term_vector_positions", storeTermVectorPositions());
|
||||
}
|
||||
if (storeTermVectorPayloads() != Defaults.IP_FIELD_TYPE.storeTermVectorPayloads()) {
|
||||
builder.field("store_term_vector_payloads", storeTermVectorPayloads());
|
||||
}
|
||||
if (omitNorms() != Defaults.IP_FIELD_TYPE.omitNorms()) {
|
||||
builder.field("omit_norms", omitNorms());
|
||||
}
|
||||
if (indexOptions() != Defaults.IP_FIELD_TYPE.indexOptions()) {
|
||||
builder.field("index_options", indexOptionToString(indexOptions()));
|
||||
}
|
||||
if (precisionStep != Defaults.PRECISION_STEP) {
|
||||
builder.field("precision_step", precisionStep);
|
||||
}
|
||||
if (similarity() != null) {
|
||||
builder.field("similarity", similarity().name());
|
||||
}
|
||||
if (nullValue != null) {
|
||||
builder.field("null_value", nullValue);
|
||||
}
|
||||
|
|
|
@ -47,7 +47,7 @@ public class UidFieldTests {
|
|||
MatcherAssert.assertThat(UidField.loadVersion(atomicReader.getContext(), new Term("_uid", "1")), equalTo(-1l));
|
||||
|
||||
Document doc = new Document();
|
||||
doc.add(new Field("_uid", "1", UidFieldMapper.Defaults.UID_FIELD_TYPE));
|
||||
doc.add(new Field("_uid", "1", UidFieldMapper.Defaults.FIELD_TYPE));
|
||||
writer.addDocument(doc);
|
||||
directoryReader = DirectoryReader.openIfChanged(directoryReader);
|
||||
atomicReader = SlowCompositeReaderWrapper.wrap(directoryReader);
|
||||
|
|
|
@ -113,11 +113,11 @@ public class CodecTests {
|
|||
.build();
|
||||
CodecService codecService = createCodecService(indexSettings);
|
||||
DocumentMapper documentMapper = codecService.mapperService().documentMapperParser().parse(mapping);
|
||||
assertThat(documentMapper.mappers().name("field1").mapper().postingFormatProvider(), instanceOf(PreBuiltPostingsFormatProvider.class));
|
||||
assertThat(documentMapper.mappers().name("field1").mapper().postingFormatProvider().get(), instanceOf(Lucene40PostingsFormat.class));
|
||||
assertThat(documentMapper.mappers().name("field1").mapper().postingsFormatProvider(), instanceOf(PreBuiltPostingsFormatProvider.class));
|
||||
assertThat(documentMapper.mappers().name("field1").mapper().postingsFormatProvider().get(), instanceOf(Lucene40PostingsFormat.class));
|
||||
|
||||
assertThat(documentMapper.mappers().name("field2").mapper().postingFormatProvider(), instanceOf(DefaultPostingsFormatProvider.class));
|
||||
DefaultPostingsFormatProvider provider = (DefaultPostingsFormatProvider) documentMapper.mappers().name("field2").mapper().postingFormatProvider();
|
||||
assertThat(documentMapper.mappers().name("field2").mapper().postingsFormatProvider(), instanceOf(DefaultPostingsFormatProvider.class));
|
||||
DefaultPostingsFormatProvider provider = (DefaultPostingsFormatProvider) documentMapper.mappers().name("field2").mapper().postingsFormatProvider();
|
||||
assertThat(provider.minBlockSize(), equalTo(16));
|
||||
assertThat(provider.maxBlockSize(), equalTo(64));
|
||||
}
|
||||
|
@ -138,11 +138,11 @@ public class CodecTests {
|
|||
.build();
|
||||
CodecService codecService = createCodecService(indexSettings);
|
||||
DocumentMapper documentMapper = codecService.mapperService().documentMapperParser().parse(mapping);
|
||||
assertThat(documentMapper.mappers().name("field1").mapper().postingFormatProvider(), instanceOf(PreBuiltPostingsFormatProvider.class));
|
||||
assertThat(documentMapper.mappers().name("field1").mapper().postingFormatProvider().get(), instanceOf(MemoryPostingsFormat.class));
|
||||
assertThat(documentMapper.mappers().name("field1").mapper().postingsFormatProvider(), instanceOf(PreBuiltPostingsFormatProvider.class));
|
||||
assertThat(documentMapper.mappers().name("field1").mapper().postingsFormatProvider().get(), instanceOf(MemoryPostingsFormat.class));
|
||||
|
||||
assertThat(documentMapper.mappers().name("field2").mapper().postingFormatProvider(), instanceOf(MemoryPostingsFormatProvider.class));
|
||||
MemoryPostingsFormatProvider provider = (MemoryPostingsFormatProvider) documentMapper.mappers().name("field2").mapper().postingFormatProvider();
|
||||
assertThat(documentMapper.mappers().name("field2").mapper().postingsFormatProvider(), instanceOf(MemoryPostingsFormatProvider.class));
|
||||
MemoryPostingsFormatProvider provider = (MemoryPostingsFormatProvider) documentMapper.mappers().name("field2").mapper().postingsFormatProvider();
|
||||
assertThat(provider.packFst(), equalTo(true));
|
||||
assertThat(provider.acceptableOverheadRatio(), equalTo(0.3f));
|
||||
}
|
||||
|
@ -163,11 +163,11 @@ public class CodecTests {
|
|||
.build();
|
||||
CodecService codecService = createCodecService(indexSettings);
|
||||
DocumentMapper documentMapper = codecService.mapperService().documentMapperParser().parse(mapping);
|
||||
assertThat(documentMapper.mappers().name("field1").mapper().postingFormatProvider(), instanceOf(PreBuiltPostingsFormatProvider.class));
|
||||
assertThat(documentMapper.mappers().name("field1").mapper().postingFormatProvider().get(), instanceOf(DirectPostingsFormat.class));
|
||||
assertThat(documentMapper.mappers().name("field1").mapper().postingsFormatProvider(), instanceOf(PreBuiltPostingsFormatProvider.class));
|
||||
assertThat(documentMapper.mappers().name("field1").mapper().postingsFormatProvider().get(), instanceOf(DirectPostingsFormat.class));
|
||||
|
||||
assertThat(documentMapper.mappers().name("field2").mapper().postingFormatProvider(), instanceOf(DirectPostingsFormatProvider.class));
|
||||
DirectPostingsFormatProvider provider = (DirectPostingsFormatProvider) documentMapper.mappers().name("field2").mapper().postingFormatProvider();
|
||||
assertThat(documentMapper.mappers().name("field2").mapper().postingsFormatProvider(), instanceOf(DirectPostingsFormatProvider.class));
|
||||
DirectPostingsFormatProvider provider = (DirectPostingsFormatProvider) documentMapper.mappers().name("field2").mapper().postingsFormatProvider();
|
||||
assertThat(provider.minSkipCount(), equalTo(16));
|
||||
assertThat(provider.lowFreqCutoff(), equalTo(64));
|
||||
}
|
||||
|
@ -189,11 +189,11 @@ public class CodecTests {
|
|||
.build();
|
||||
CodecService codecService = createCodecService(indexSettings);
|
||||
DocumentMapper documentMapper = codecService.mapperService().documentMapperParser().parse(mapping);
|
||||
assertThat(documentMapper.mappers().name("field1").mapper().postingFormatProvider(), instanceOf(PreBuiltPostingsFormatProvider.class));
|
||||
assertThat(documentMapper.mappers().name("field1").mapper().postingFormatProvider().get(), instanceOf(Pulsing40PostingsFormat.class));
|
||||
assertThat(documentMapper.mappers().name("field1").mapper().postingsFormatProvider(), instanceOf(PreBuiltPostingsFormatProvider.class));
|
||||
assertThat(documentMapper.mappers().name("field1").mapper().postingsFormatProvider().get(), instanceOf(Pulsing40PostingsFormat.class));
|
||||
|
||||
assertThat(documentMapper.mappers().name("field2").mapper().postingFormatProvider(), instanceOf(PulsingPostingsFormatProvider.class));
|
||||
PulsingPostingsFormatProvider provider = (PulsingPostingsFormatProvider) documentMapper.mappers().name("field2").mapper().postingFormatProvider();
|
||||
assertThat(documentMapper.mappers().name("field2").mapper().postingsFormatProvider(), instanceOf(PulsingPostingsFormatProvider.class));
|
||||
PulsingPostingsFormatProvider provider = (PulsingPostingsFormatProvider) documentMapper.mappers().name("field2").mapper().postingsFormatProvider();
|
||||
assertThat(provider.freqCutOff(), equalTo(2));
|
||||
assertThat(provider.minBlockSize(), equalTo(32));
|
||||
assertThat(provider.maxBlockSize(), equalTo(64));
|
||||
|
@ -220,14 +220,14 @@ public class CodecTests {
|
|||
.build();
|
||||
CodecService codecService = createCodecService(indexSettings);
|
||||
DocumentMapper documentMapper = codecService.mapperService().documentMapperParser().parse(mapping);
|
||||
assertThat(documentMapper.mappers().name("field1").mapper().postingFormatProvider(), instanceOf(PreBuiltPostingsFormatProvider.class));
|
||||
assertThat(documentMapper.mappers().name("field1").mapper().postingFormatProvider().get(), instanceOf(BloomFilteringPostingsFormat.class));
|
||||
assertThat(documentMapper.mappers().name("field1").mapper().postingsFormatProvider(), instanceOf(PreBuiltPostingsFormatProvider.class));
|
||||
assertThat(documentMapper.mappers().name("field1").mapper().postingsFormatProvider().get(), instanceOf(BloomFilteringPostingsFormat.class));
|
||||
|
||||
assertThat(documentMapper.mappers().name("field2").mapper().postingFormatProvider(), instanceOf(PreBuiltPostingsFormatProvider.class));
|
||||
assertThat(documentMapper.mappers().name("field2").mapper().postingFormatProvider().get(), instanceOf(BloomFilteringPostingsFormat.class));
|
||||
assertThat(documentMapper.mappers().name("field2").mapper().postingsFormatProvider(), instanceOf(PreBuiltPostingsFormatProvider.class));
|
||||
assertThat(documentMapper.mappers().name("field2").mapper().postingsFormatProvider().get(), instanceOf(BloomFilteringPostingsFormat.class));
|
||||
|
||||
assertThat(documentMapper.mappers().name("field3").mapper().postingFormatProvider(), instanceOf(BloomFilterPostingsFormatProvider.class));
|
||||
BloomFilterPostingsFormatProvider provider = (BloomFilterPostingsFormatProvider) documentMapper.mappers().name("field3").mapper().postingFormatProvider();
|
||||
assertThat(documentMapper.mappers().name("field3").mapper().postingsFormatProvider(), instanceOf(BloomFilterPostingsFormatProvider.class));
|
||||
BloomFilterPostingsFormatProvider provider = (BloomFilterPostingsFormatProvider) documentMapper.mappers().name("field3").mapper().postingsFormatProvider();
|
||||
assertThat(provider.desiredMaxSaturation(), equalTo(0.2f));
|
||||
assertThat(provider.saturationLimit(), equalTo(0.8f));
|
||||
assertThat(provider.delegate(), instanceOf(DirectPostingsFormatProvider.class));
|
||||
|
|
|
@ -231,7 +231,7 @@ public abstract class AbstractSimpleEngineTests {
|
|||
|
||||
// create a document
|
||||
Document document = testDocumentWithTextField("1");
|
||||
document.add(new Field(SourceFieldMapper.NAME, B_1.toBytes(), SourceFieldMapper.Defaults.SOURCE_FIELD_TYPE));
|
||||
document.add(new Field(SourceFieldMapper.NAME, B_1.toBytes(), SourceFieldMapper.Defaults.FIELD_TYPE));
|
||||
ParsedDocument doc = new ParsedDocument("1", "1", "test", null, -1, -1, document, Lucene.STANDARD_ANALYZER, B_1, false);
|
||||
engine.create(new Engine.Create(null, newUid("1"), doc));
|
||||
|
||||
|
@ -268,7 +268,7 @@ public abstract class AbstractSimpleEngineTests {
|
|||
// now do an update
|
||||
document = testDocument("1");
|
||||
document.add(new TextField("value", "test1", Field.Store.YES));
|
||||
document.add(new Field(SourceFieldMapper.NAME, B_2.toBytes(), SourceFieldMapper.Defaults.SOURCE_FIELD_TYPE));
|
||||
document.add(new Field(SourceFieldMapper.NAME, B_2.toBytes(), SourceFieldMapper.Defaults.FIELD_TYPE));
|
||||
doc = new ParsedDocument("1", "1", "test", null, -1, -1, document, Lucene.STANDARD_ANALYZER, B_2, false);
|
||||
engine.index(new Engine.Index(null, newUid("1"), doc));
|
||||
|
||||
|
@ -319,7 +319,7 @@ public abstract class AbstractSimpleEngineTests {
|
|||
|
||||
// add it back
|
||||
document = testDocumentWithTextField("1");
|
||||
document.add(new Field(SourceFieldMapper.NAME, B_1.toBytes(), SourceFieldMapper.Defaults.SOURCE_FIELD_TYPE));
|
||||
document.add(new Field(SourceFieldMapper.NAME, B_1.toBytes(), SourceFieldMapper.Defaults.FIELD_TYPE));
|
||||
doc = new ParsedDocument("1", "1", "test", null, -1, -1, document, Lucene.STANDARD_ANALYZER, B_1, false);
|
||||
engine.create(new Engine.Create(null, newUid("1"), doc));
|
||||
|
||||
|
|
|
@ -73,8 +73,8 @@ public class TimestampMappingTests {
|
|||
String mapping = XContentFactory.jsonBuilder().startObject().startObject("type").endObject().string();
|
||||
DocumentMapper docMapper = MapperTests.newParser().parse(mapping);
|
||||
assertThat(docMapper.timestampFieldMapper().enabled(), equalTo(TimestampFieldMapper.Defaults.ENABLED));
|
||||
assertThat(docMapper.timestampFieldMapper().stored(), equalTo(TimestampFieldMapper.Defaults.TIMESTAMP_FIELD_TYPE.stored()));
|
||||
assertThat(docMapper.timestampFieldMapper().indexed(), equalTo(TimestampFieldMapper.Defaults.TIMESTAMP_FIELD_TYPE.indexed()));
|
||||
assertThat(docMapper.timestampFieldMapper().stored(), equalTo(TimestampFieldMapper.Defaults.FIELD_TYPE.stored()));
|
||||
assertThat(docMapper.timestampFieldMapper().indexed(), equalTo(TimestampFieldMapper.Defaults.FIELD_TYPE.indexed()));
|
||||
assertThat(docMapper.timestampFieldMapper().path(), equalTo(null));
|
||||
assertThat(docMapper.timestampFieldMapper().dateTimeFormatter().format(), equalTo(TimestampFieldMapper.DEFAULT_DATE_TIME_FORMAT));
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue