Move stored flag from TextSearchInfo to MappedFieldType (#62717) (#62770)

This commit is contained in:
Luca Cavanna 2020-09-23 09:40:34 +02:00 committed by GitHub
parent b4ec821067
commit 5ca86d541c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
85 changed files with 260 additions and 271 deletions

View File

@ -100,7 +100,7 @@ public class RankFeatureFieldMapper extends FieldMapper {
private final boolean positiveScoreImpact;
public RankFeatureFieldType(String name, Map<String, String> meta, boolean positiveScoreImpact) {
super(name, true, false, TextSearchInfo.NONE, meta);
super(name, true, false, false, TextSearchInfo.NONE, meta);
this.positiveScoreImpact = positiveScoreImpact;
setIndexAnalyzer(Lucene.KEYWORD_ANALYZER);
}

View File

@ -42,7 +42,7 @@ public class RankFeatureMetaFieldMapper extends MetadataFieldMapper {
public static final RankFeatureMetaFieldType INSTANCE = new RankFeatureMetaFieldType();
private RankFeatureMetaFieldType() {
super(NAME, false, false, TextSearchInfo.NONE, Collections.emptyMap());
super(NAME, false, false, false, TextSearchInfo.NONE, Collections.emptyMap());
}
@Override

View File

@ -78,7 +78,7 @@ public class RankFeaturesFieldMapper extends FieldMapper {
public static final class RankFeaturesFieldType extends MappedFieldType {
public RankFeaturesFieldType(String name, Map<String, String> meta) {
super(name, false, false, TextSearchInfo.NONE, meta);
super(name, false, false, false, TextSearchInfo.NONE, meta);
setIndexAnalyzer(Lucene.KEYWORD_ANALYZER);
}

View File

@ -126,8 +126,8 @@ public class ScaledFloatFieldMapper extends ParametrizedFieldMapper {
@Override
public ScaledFloatFieldMapper build(BuilderContext context) {
ScaledFloatFieldType type = new ScaledFloatFieldType(buildFullName(context), indexed.getValue(), hasDocValues.getValue(),
meta.getValue(), scalingFactor.getValue());
ScaledFloatFieldType type = new ScaledFloatFieldType(buildFullName(context), indexed.getValue(), stored.getValue(),
hasDocValues.getValue(), meta.getValue(), scalingFactor.getValue());
return new ScaledFloatFieldMapper(name, type, multiFieldsBuilder.build(this, context), copyTo.build(), this);
}
}
@ -138,13 +138,14 @@ public class ScaledFloatFieldMapper extends ParametrizedFieldMapper {
private final double scalingFactor;
public ScaledFloatFieldType(String name, boolean indexed, boolean hasDocValues, Map<String, String> meta, double scalingFactor) {
super(name, indexed, hasDocValues, TextSearchInfo.SIMPLE_MATCH_ONLY, meta);
public ScaledFloatFieldType(String name, boolean indexed, boolean stored, boolean hasDocValues,
Map<String, String> meta, double scalingFactor) {
super(name, indexed, stored, hasDocValues, TextSearchInfo.SIMPLE_MATCH_ONLY, meta);
this.scalingFactor = scalingFactor;
}
public ScaledFloatFieldType(String name, double scalingFactor) {
this(name, true, true, Collections.emptyMap(), scalingFactor);
this(name, true, false, true, Collections.emptyMap(), scalingFactor);
}
public double getScalingFactor() {

View File

@ -249,7 +249,7 @@ public class SearchAsYouTypeFieldMapper extends FieldMapper {
SearchAsYouTypeFieldType(String name, FieldType fieldType, SimilarityProvider similarity,
NamedAnalyzer searchAnalyzer, NamedAnalyzer searchQuoteAnalyzer, Map<String, String> meta) {
super(name, fieldType.indexOptions() != IndexOptions.NONE, false,
super(name, fieldType.indexOptions() != IndexOptions.NONE, fieldType.stored(), false,
new TextSearchInfo(fieldType, similarity, searchAnalyzer, searchQuoteAnalyzer), meta);
}
@ -354,7 +354,7 @@ public class SearchAsYouTypeFieldMapper extends FieldMapper {
final String parentField;
PrefixFieldType(String parentField, TextSearchInfo textSearchInfo, int minChars, int maxChars) {
super(parentField + PREFIX_FIELD_SUFFIX, true, false, textSearchInfo, Collections.emptyMap());
super(parentField + PREFIX_FIELD_SUFFIX, true, false, false, textSearchInfo, Collections.emptyMap());
this.minChars = minChars;
this.maxChars = maxChars;
this.parentField = parentField;
@ -487,7 +487,7 @@ public class SearchAsYouTypeFieldMapper extends FieldMapper {
PrefixFieldType prefixFieldType;
ShingleFieldType(String name, int shingleSize, TextSearchInfo textSearchInfo) {
super(name, true, false, textSearchInfo, Collections.emptyMap());
super(name, true, false, false, textSearchInfo, Collections.emptyMap());
this.shingleSize = shingleSize;
}

View File

@ -65,7 +65,7 @@ public class ScaledFloatFieldTypeTests extends FieldTypeTestCase {
// this test checks that searching scaled floats yields the same results as
// searching doubles that are rounded to the closest half float
ScaledFloatFieldMapper.ScaledFloatFieldType ft = new ScaledFloatFieldMapper.ScaledFloatFieldType(
"scaled_float", true, false, Collections.emptyMap(), 0.1 + randomDouble() * 100);
"scaled_float", true, false, false, Collections.emptyMap(), 0.1 + randomDouble() * 100);
Directory dir = newDirectory();
IndexWriter w = new IndexWriter(dir, new IndexWriterConfig(null));
final int numDocs = 1000;

View File

@ -82,7 +82,7 @@ public class MetaJoinFieldMapper extends FieldMapper {
private final String joinField;
MetaJoinFieldType(String joinField) {
super(NAME, false, false, TextSearchInfo.SIMPLE_MATCH_ONLY, Collections.emptyMap());
super(NAME, false, false, false, TextSearchInfo.SIMPLE_MATCH_ONLY, Collections.emptyMap());
this.joinField = joinField;
}

View File

@ -99,7 +99,7 @@ public final class ParentIdFieldMapper extends FieldMapper {
public static final class ParentIdFieldType extends StringFieldType {
ParentIdFieldType(String name, boolean eagerGlobalOrdinals, Map<String, String> meta) {
super(name, true, true, TextSearchInfo.SIMPLE_MATCH_ONLY, meta);
super(name, true, false, true, TextSearchInfo.SIMPLE_MATCH_ONLY, meta);
setIndexAnalyzer(Lucene.KEYWORD_ANALYZER);
setEagerGlobalOrdinals(eagerGlobalOrdinals);
}

View File

@ -210,7 +210,7 @@ public final class ParentJoinFieldMapper extends FieldMapper {
public static final class JoinFieldType extends StringFieldType {
public JoinFieldType(String name, Map<String, String> meta) {
super(name, true, true, TextSearchInfo.SIMPLE_MATCH_ONLY, meta);
super(name, true, false, true, TextSearchInfo.SIMPLE_MATCH_ONLY, meta);
setIndexAnalyzer(Lucene.KEYWORD_ANALYZER);
}

View File

@ -199,7 +199,7 @@ public class PercolatorFieldMapper extends FieldMapper {
boolean mapUnmappedFieldsAsText;
PercolatorFieldType(String name, Map<String, String> meta) {
super(name, false, false, TextSearchInfo.NONE, meta);
super(name, false, false, false, TextSearchInfo.NONE, meta);
}
@Override

View File

@ -78,14 +78,15 @@ public class ICUCollationKeywordFieldMapper extends FieldMapper {
public static final class CollationFieldType extends StringFieldType {
private final Collator collator;
public CollationFieldType(String name, boolean isSearchable, boolean hasDocValues, Collator collator, Map<String, String> meta) {
super(name, isSearchable, hasDocValues, TextSearchInfo.SIMPLE_MATCH_ONLY, meta);
public CollationFieldType(String name, boolean isSearchable, boolean isStored, boolean hasDocValues,
Collator collator, Map<String, String> meta) {
super(name, isSearchable, isStored, hasDocValues, TextSearchInfo.SIMPLE_MATCH_ONLY, meta);
setIndexAnalyzer(Lucene.KEYWORD_ANALYZER);
this.collator = collator;
}
public CollationFieldType(String name, Collator collator) {
this(name, true, true, collator, Collections.emptyMap());
this(name, true, false, true, collator, Collections.emptyMap());
}
@Override
@ -136,7 +137,7 @@ public class ICUCollationKeywordFieldMapper extends FieldMapper {
}
@Override
public Query prefixQuery(String value, MultiTermQuery.RewriteMethod method,
public Query prefixQuery(String value, MultiTermQuery.RewriteMethod method,
boolean caseInsensitive, QueryShardContext context) {
throw new UnsupportedOperationException("[prefix] queries are not supported on [" + CONTENT_TYPE + "] fields.");
}
@ -440,7 +441,8 @@ public class ICUCollationKeywordFieldMapper extends FieldMapper {
@Override
public ICUCollationKeywordFieldMapper build(BuilderContext context) {
final Collator collator = buildCollator();
CollationFieldType ft = new CollationFieldType(buildFullName(context), indexed, hasDocValues, collator, meta);
CollationFieldType ft = new CollationFieldType(buildFullName(context), indexed, fieldType.stored(), hasDocValues,
collator, meta);
return new ICUCollationKeywordFieldMapper(name, fieldType, ft,
multiFieldsBuilder.build(this, context), copyTo, rules, language, country, variant, strength, decomposition,
alternate, caseLevel, caseFirst, numeric, variableTop, hiraganaQuaternaryMode, ignoreAbove, collator, nullValue);

View File

@ -66,7 +66,7 @@ public class CollationFieldTypeTests extends FieldTypeTestCase{
assertEquals(new TermQuery(new Term("field", expected)), ft.termQuery("I WİLL USE TURKİSH CASING", null));
MappedFieldType unsearchable = new CollationFieldType("field", false, true, collator, Collections.emptyMap());
MappedFieldType unsearchable = new CollationFieldType("field", false, false, true, collator, Collections.emptyMap());
IllegalArgumentException e = expectThrows(IllegalArgumentException.class,
() -> unsearchable.termQuery("bar", null));
assertEquals("Cannot search on field [field] since it is not indexed.", e.getMessage());
@ -86,7 +86,7 @@ public class CollationFieldTypeTests extends FieldTypeTestCase{
assertEquals(new TermInSetQuery("field", terms),
ft.termsQuery(Arrays.asList("foo", "bar"), null));
MappedFieldType unsearchable = new CollationFieldType("field", false, true, collator, Collections.emptyMap());
MappedFieldType unsearchable = new CollationFieldType("field", false, false, true, collator, Collections.emptyMap());
IllegalArgumentException e = expectThrows(IllegalArgumentException.class,
() -> unsearchable.termsQuery(Arrays.asList("foo", "bar"), null));
assertEquals("Cannot search on field [field] since it is not indexed.", e.getMessage());
@ -135,7 +135,7 @@ public class CollationFieldTypeTests extends FieldTypeTestCase{
assertEquals("[range] queries on [text] or [keyword] fields cannot be executed when " +
"'search.allow_expensive_queries' is set to false.", ee.getMessage());
MappedFieldType unsearchable = new CollationFieldType("field", false, true, DEFAULT_COLLATOR, Collections.emptyMap());
MappedFieldType unsearchable = new CollationFieldType("field", false, false, true, DEFAULT_COLLATOR, Collections.emptyMap());
IllegalArgumentException e = expectThrows(IllegalArgumentException.class,
() -> unsearchable.rangeQuery("a", "b", false, false, null, null, null, MOCK_QSC));
assertEquals("Cannot search on field [field] since it is not indexed.", e.getMessage());

View File

@ -403,8 +403,6 @@ public class AnnotatedTextFieldMapper extends FieldMapper {
}
}
@Override
public void reset() throws IOException {
pendingStates.clear();
@ -469,6 +467,7 @@ public class AnnotatedTextFieldMapper extends FieldMapper {
return false;
}
}
private void setType(AnnotationToken token) {
//Default annotation type - in future AnnotationTokens may contain custom type info
typeAtt.setType("annotation");
@ -515,7 +514,6 @@ public class AnnotatedTextFieldMapper extends FieldMapper {
}
public static final class AnnotatedTextFieldType extends TextFieldMapper.TextFieldType {
public AnnotatedTextFieldType(String name, FieldType fieldType, SimilarityProvider similarity,
@ -524,7 +522,7 @@ public class AnnotatedTextFieldMapper extends FieldMapper {
}
public AnnotatedTextFieldType(String name, Map<String, String> meta) {
super(name, true, meta);
super(name, true, false, meta);
}
public void setIndexAnalyzer(NamedAnalyzer delegate, int positionIncrementGap) {
@ -542,7 +540,6 @@ public class AnnotatedTextFieldMapper extends FieldMapper {
public String typeName() {
return CONTENT_TYPE;
}
}
private int positionIncrementGap;

View File

@ -70,7 +70,7 @@ public class Murmur3FieldMapper extends FieldMapper {
@Override
public Murmur3FieldMapper build(BuilderContext context) {
return new Murmur3FieldMapper(name, fieldType, new Murmur3FieldType(buildFullName(context), meta),
return new Murmur3FieldMapper(name, fieldType, new Murmur3FieldType(buildFullName(context), fieldType.stored(), meta),
multiFieldsBuilder.build(this, context), copyTo);
}
}
@ -97,8 +97,8 @@ public class Murmur3FieldMapper extends FieldMapper {
// this only exists so a check can be done to match the field type to using murmur3 hashing...
public static class Murmur3FieldType extends MappedFieldType {
public Murmur3FieldType(String name, Map<String, String> meta) {
super(name, false, true, TextSearchInfo.SIMPLE_MATCH_ONLY, meta);
public Murmur3FieldType(String name, boolean isStored, Map<String, String> meta) {
super(name, false, isStored, true, TextSearchInfo.SIMPLE_MATCH_ONLY, meta);
}
@Override

View File

@ -246,8 +246,8 @@ public abstract class AbstractGeometryFieldMapper<Parsed, Processed> extends Fie
protected Parser<Parsed> geometryParser;
protected QueryProcessor geometryQueryBuilder;
protected AbstractGeometryFieldType(String name, boolean indexed, boolean hasDocValues, Map<String, String> meta) {
super(name, indexed, hasDocValues, TextSearchInfo.SIMPLE_MATCH_ONLY, meta);
protected AbstractGeometryFieldType(String name, boolean indexed, boolean stored, boolean hasDocValues, Map<String, String> meta) {
super(name, indexed, stored, hasDocValues, TextSearchInfo.SIMPLE_MATCH_ONLY, meta);
}
public void setGeometryQueryBuilder(QueryProcessor geometryQueryBuilder) {

View File

@ -114,8 +114,9 @@ public abstract class AbstractPointGeometryFieldMapper<Parsed, Processed> extend
public abstract static class AbstractPointGeometryFieldType<Parsed, Processed>
extends AbstractGeometryFieldType<Parsed, Processed> {
protected AbstractPointGeometryFieldType(String name, boolean indexed, boolean hasDocValues, Map<String, String> meta) {
super(name, indexed, hasDocValues, meta);
protected AbstractPointGeometryFieldType(String name, boolean indexed, boolean stored, boolean hasDocValues,
Map<String, String> meta) {
super(name, indexed, stored, hasDocValues, meta);
}
}

View File

@ -157,8 +157,9 @@ public abstract class AbstractShapeGeometryFieldMapper<Parsed, Processed> extend
public abstract static class AbstractShapeGeometryFieldType<Parsed, Processed> extends AbstractGeometryFieldType<Parsed, Processed> {
protected Orientation orientation = Defaults.ORIENTATION.value();
protected AbstractShapeGeometryFieldType(String name, boolean isSearchable, boolean hasDocValues, Map<String, String> meta) {
super(name, isSearchable, hasDocValues, meta);
protected AbstractShapeGeometryFieldType(String name, boolean isSearchable, boolean isStored, boolean hasDocValues,
Map<String, String> meta) {
super(name, isSearchable, isStored, hasDocValues, meta);
}
public Orientation orientation() { return this.orientation; }

View File

@ -82,7 +82,7 @@ public class AllFieldMapper extends MetadataFieldMapper {
static final class AllFieldType extends StringFieldType {
AllFieldType() {
super(NAME, false, false, TextSearchInfo.NONE, Collections.emptyMap());
super(NAME, false, false, false, TextSearchInfo.NONE, Collections.emptyMap());
}
@Override

View File

@ -79,8 +79,8 @@ public class BinaryFieldMapper extends ParametrizedFieldMapper {
@Override
public BinaryFieldMapper build(BuilderContext context) {
return new BinaryFieldMapper(name, new BinaryFieldType(buildFullName(context), hasDocValues.getValue(), meta.getValue()),
multiFieldsBuilder.build(this, context), copyTo.build(), this);
return new BinaryFieldMapper(name, new BinaryFieldType(buildFullName(context), stored.getValue(),
hasDocValues.getValue(), meta.getValue()), multiFieldsBuilder.build(this, context), copyTo.build(), this);
}
}
@ -88,12 +88,12 @@ public class BinaryFieldMapper extends ParametrizedFieldMapper {
public static final class BinaryFieldType extends MappedFieldType {
public BinaryFieldType(String name, boolean hasDocValues, Map<String, String> meta) {
super(name, false, hasDocValues, TextSearchInfo.NONE, meta);
public BinaryFieldType(String name, boolean isStored, boolean hasDocValues, Map<String, String> meta) {
super(name, false, isStored, hasDocValues, TextSearchInfo.NONE, meta);
}
public BinaryFieldType(String name) {
this(name, true, Collections.emptyMap());
this(name, false, true, Collections.emptyMap());
}
@Override

View File

@ -100,7 +100,8 @@ public class BooleanFieldMapper extends ParametrizedFieldMapper {
@Override
public BooleanFieldMapper build(BuilderContext context) {
MappedFieldType ft = new BooleanFieldType(buildFullName(context), indexed.getValue(), docValues.getValue(), meta.getValue());
MappedFieldType ft = new BooleanFieldType(buildFullName(context), indexed.getValue(), stored.getValue(),
docValues.getValue(), meta.getValue());
ft.setBoost(boost.getValue());
return new BooleanFieldMapper(name, ft, multiFieldsBuilder.build(this, context), copyTo.build(), this);
}
@ -110,12 +111,13 @@ public class BooleanFieldMapper extends ParametrizedFieldMapper {
public static final class BooleanFieldType extends TermBasedFieldType {
public BooleanFieldType(String name, boolean isSearchable, boolean hasDocValues, Map<String, String> meta) {
super(name, isSearchable, hasDocValues, TextSearchInfo.SIMPLE_MATCH_ONLY, meta);
public BooleanFieldType(String name, boolean isSearchable, boolean isStored, boolean hasDocValues,
Map<String, String> meta) {
super(name, isSearchable, isStored, hasDocValues, TextSearchInfo.SIMPLE_MATCH_ONLY, meta);
}
public BooleanFieldType(String name) {
this(name, true, true, Collections.emptyMap());
this(name, true, false, true, Collections.emptyMap());
}
@Override

View File

@ -237,8 +237,7 @@ public class CompletionFieldMapper extends ParametrizedFieldMapper {
private ContextMappings contextMappings = null;
public CompletionFieldType(String name, NamedAnalyzer searchAnalyzer, Map<String, String> meta) {
super(name, true, false,
new TextSearchInfo(Defaults.FIELD_TYPE, null, searchAnalyzer, searchAnalyzer), meta);
super(name, true, false, false, new TextSearchInfo(Defaults.FIELD_TYPE, null, searchAnalyzer, searchAnalyzer), meta);
}
public void setPreserveSep(boolean preserveSep) {

View File

@ -42,7 +42,7 @@ import java.util.Map;
public abstract class ConstantFieldType extends MappedFieldType {
public ConstantFieldType(String name, Map<String, String> meta) {
super(name, true, true, TextSearchInfo.SIMPLE_MATCH_ONLY, meta);
super(name, true, false, true, TextSearchInfo.SIMPLE_MATCH_ONLY, meta);
}
@Override
@ -86,7 +86,7 @@ public abstract class ConstantFieldType extends MappedFieldType {
return new MatchNoDocsQuery();
}
}
@Override
public final Query termsQuery(List<?> values, QueryShardContext context) {
for (Object value : values) {
@ -97,12 +97,12 @@ public abstract class ConstantFieldType extends MappedFieldType {
}
}
return new MatchNoDocsQuery();
}
}
@Override
public final Query prefixQuery(String prefix,
@Nullable MultiTermQuery.RewriteMethod method,
boolean caseInsensitive,
boolean caseInsensitive,
QueryShardContext context) {
String pattern = prefix + "*";
if (matches(pattern, caseInsensitive, context)) {
@ -115,7 +115,7 @@ public abstract class ConstantFieldType extends MappedFieldType {
@Override
public final Query wildcardQuery(String value,
@Nullable MultiTermQuery.RewriteMethod method,
boolean caseInsensitive,
boolean caseInsensitive,
QueryShardContext context) {
if (matches(value, caseInsensitive, context)) {
return Queries.newMatchAllQuery();
@ -123,5 +123,4 @@ public abstract class ConstantFieldType extends MappedFieldType {
return new MatchNoDocsQuery();
}
}
}

View File

@ -253,7 +253,7 @@ public final class DateFieldMapper extends ParametrizedFieldMapper {
@Override
public DateFieldMapper build(BuilderContext context) {
DateFieldType ft = new DateFieldType(buildFullName(context), index.getValue(), docValues.getValue(),
DateFieldType ft = new DateFieldType(buildFullName(context), index.getValue(), store.getValue(), docValues.getValue(),
buildFormatter(), resolution, meta.getValue());
ft.setBoost(boost.getValue());
Long nullTimestamp = parseNullValue(ft);
@ -277,24 +277,24 @@ public final class DateFieldMapper extends ParametrizedFieldMapper {
protected final DateMathParser dateMathParser;
protected final Resolution resolution;
public DateFieldType(String name, boolean isSearchable, boolean hasDocValues,
public DateFieldType(String name, boolean isSearchable, boolean isStored, boolean hasDocValues,
DateFormatter dateTimeFormatter, Resolution resolution, Map<String, String> meta) {
super(name, isSearchable, hasDocValues, TextSearchInfo.SIMPLE_MATCH_ONLY, meta);
super(name, isSearchable, isStored, hasDocValues, TextSearchInfo.SIMPLE_MATCH_ONLY, meta);
this.dateTimeFormatter = dateTimeFormatter;
this.dateMathParser = dateTimeFormatter.toDateMathParser();
this.resolution = resolution;
}
public DateFieldType(String name) {
this(name, true, true, DEFAULT_DATE_TIME_FORMATTER, Resolution.MILLISECONDS, Collections.emptyMap());
this(name, true, false, true, DEFAULT_DATE_TIME_FORMATTER, Resolution.MILLISECONDS, Collections.emptyMap());
}
public DateFieldType(String name, DateFormatter dateFormatter) {
this(name, true, true, dateFormatter, Resolution.MILLISECONDS, Collections.emptyMap());
this(name, true, false, true, dateFormatter, Resolution.MILLISECONDS, Collections.emptyMap());
}
public DateFieldType(String name, Resolution resolution) {
this(name, true, true, DEFAULT_DATE_TIME_FORMATTER, resolution, Collections.emptyMap());
this(name, true, false, true, DEFAULT_DATE_TIME_FORMATTER, resolution, Collections.emptyMap());
}
@Override

View File

@ -115,7 +115,7 @@ public class FieldNamesFieldMapper extends MetadataFieldMapper {
private final boolean enabled;
public FieldNamesFieldType(boolean enabled) {
super(Defaults.NAME, true, false, TextSearchInfo.SIMPLE_MATCH_ONLY, Collections.emptyMap());
super(Defaults.NAME, true, false, false, TextSearchInfo.SIMPLE_MATCH_ONLY, Collections.emptyMap());
this.enabled = enabled;
}

View File

@ -74,7 +74,7 @@ public class GeoPointFieldMapper extends AbstractPointGeometryFieldMapper<List<P
public GeoPointFieldMapper build(BuilderContext context, String simpleName, FieldType fieldType,
MultiFields multiFields, Explicit<Boolean> ignoreMalformed,
Explicit<Boolean> ignoreZValue, ParsedPoint nullValue, CopyTo copyTo) {
GeoPointFieldType ft = new GeoPointFieldType(buildFullName(context), indexed, hasDocValues, meta);
GeoPointFieldType ft = new GeoPointFieldType(buildFullName(context), indexed, fieldType.stored(), hasDocValues, meta);
ft.setGeometryParser(new PointParser<>());
ft.setGeometryIndexer(new GeoPointIndexer(ft));
ft.setGeometryQueryBuilder(new VectorGeoPointShapeQueryProcessor());
@ -172,12 +172,12 @@ public class GeoPointFieldMapper extends AbstractPointGeometryFieldMapper<List<P
}
public static class GeoPointFieldType extends AbstractPointGeometryFieldType<List<ParsedGeoPoint>, List<? extends GeoPoint>> {
public GeoPointFieldType(String name, boolean indexed, boolean hasDocValues, Map<String, String> meta) {
super(name, indexed, hasDocValues, meta);
public GeoPointFieldType(String name, boolean indexed, boolean stored, boolean hasDocValues, Map<String, String> meta) {
super(name, indexed, stored, hasDocValues, meta);
}
public GeoPointFieldType(String name) {
this(name, true, true, Collections.emptyMap());
this(name, true, false, true, Collections.emptyMap());
}
@Override

View File

@ -68,7 +68,7 @@ public class GeoShapeFieldMapper extends AbstractShapeGeometryFieldMapper<Geomet
}
private GeoShapeFieldType buildFieldType(BuilderContext context) {
GeoShapeFieldType ft = new GeoShapeFieldType(buildFullName(context), indexed, hasDocValues, meta);
GeoShapeFieldType ft = new GeoShapeFieldType(buildFullName(context), indexed, fieldType.stored(), hasDocValues, meta);
GeometryParser geometryParser = new GeometryParser(ft.orientation.getAsBoolean(), coerce().value(),
ignoreZValue().value());
ft.setGeometryParser(new GeoShapeParser(geometryParser));
@ -87,8 +87,8 @@ public class GeoShapeFieldMapper extends AbstractShapeGeometryFieldMapper<Geomet
}
public static class GeoShapeFieldType extends AbstractShapeGeometryFieldType<Geometry, Geometry> {
public GeoShapeFieldType(String name, boolean indexed, boolean hasDocValues, Map<String, String> meta) {
super(name, indexed, hasDocValues, meta);
public GeoShapeFieldType(String name, boolean indexed, boolean stored, boolean hasDocValues, Map<String, String> meta) {
super(name, indexed, stored, hasDocValues, meta);
}
@Override

View File

@ -102,7 +102,7 @@ public class IdFieldMapper extends MetadataFieldMapper {
public static final IdFieldType INSTANCE = new IdFieldType();
private IdFieldType() {
super(NAME, true, false, TextSearchInfo.SIMPLE_MATCH_ONLY, Collections.emptyMap());
super(NAME, true, true, false, TextSearchInfo.SIMPLE_MATCH_ONLY, Collections.emptyMap());
setIndexAnalyzer(Lucene.KEYWORD_ANALYZER);
}

View File

@ -26,7 +26,6 @@ import org.apache.lucene.search.Query;
import org.apache.lucene.search.TermRangeQuery;
import org.elasticsearch.index.query.QueryShardContext;
import java.io.IOException;
import java.util.Collections;
/**
@ -59,7 +58,7 @@ public final class IgnoredFieldMapper extends MetadataFieldMapper {
public static final IgnoredFieldType INSTANCE = new IgnoredFieldType();
private IgnoredFieldType() {
super(NAME, true, false, TextSearchInfo.SIMPLE_MATCH_ONLY, Collections.emptyMap());
super(NAME, true, true, false, TextSearchInfo.SIMPLE_MATCH_ONLY, Collections.emptyMap());
}
@Override
@ -75,7 +74,6 @@ public final class IgnoredFieldMapper extends MetadataFieldMapper {
// field is bounded by the number of fields in the mappings.
return new TermRangeQuery(name(), null, null, true, true);
}
}
private IgnoredFieldMapper() {
@ -83,7 +81,7 @@ public final class IgnoredFieldMapper extends MetadataFieldMapper {
}
@Override
public void postParse(ParseContext context) throws IOException {
public void postParse(ParseContext context) {
for (String field : context.getIgnoredFields()) {
context.doc().add(new Field(NAME, field, Defaults.FIELD_TYPE));
}

View File

@ -58,7 +58,7 @@ public class IndexFieldMapper extends MetadataFieldMapper {
// Thankfully, all index names are lower-cased so we don't have to pass a case_insensitive mode flag
// down to all the index name-matching logic. We just lower-case the search string
pattern = Strings.toLowercaseAscii(pattern);
}
}
return context.indexMatches(pattern);
}
@ -71,7 +71,6 @@ public class IndexFieldMapper extends MetadataFieldMapper {
public IndexFieldData.Builder fielddataBuilder(String fullyQualifiedIndexName, Supplier<SearchLookup> searchLookup) {
return new ConstantIndexFieldData.Builder(mapperService -> fullyQualifiedIndexName, name(), CoreValuesSourceType.BYTES);
}
}
public IndexFieldMapper() {
@ -82,5 +81,4 @@ public class IndexFieldMapper extends MetadataFieldMapper {
protected String contentType() {
return CONTENT_TYPE;
}
}

View File

@ -114,7 +114,7 @@ public class IpFieldMapper extends ParametrizedFieldMapper {
@Override
public IpFieldMapper build(BuilderContext context) {
return new IpFieldMapper(name,
new IpFieldType(buildFullName(context), indexed.getValue(), hasDocValues.getValue(), meta.getValue()),
new IpFieldType(buildFullName(context), indexed.getValue(), stored.getValue(), hasDocValues.getValue(), meta.getValue()),
multiFieldsBuilder.build(this, context), copyTo.build(), this);
}
@ -127,12 +127,12 @@ public class IpFieldMapper extends ParametrizedFieldMapper {
public static final class IpFieldType extends SimpleMappedFieldType {
public IpFieldType(String name, boolean indexed, boolean hasDocValues, Map<String, String> meta) {
super(name, indexed, hasDocValues, TextSearchInfo.SIMPLE_MATCH_ONLY, meta);
public IpFieldType(String name, boolean indexed, boolean stored, boolean hasDocValues, Map<String, String> meta) {
super(name, indexed, stored, hasDocValues, TextSearchInfo.SIMPLE_MATCH_ONLY, meta);
}
public IpFieldType(String name) {
this(name, true, true, Collections.emptyMap());
this(name, true, false, true, Collections.emptyMap());
}
@Override

View File

@ -208,7 +208,7 @@ public final class KeywordFieldMapper extends ParametrizedFieldMapper {
public KeywordFieldType(String name, boolean hasDocValues, FieldType fieldType,
boolean eagerGlobalOrdinals, NamedAnalyzer normalizer, NamedAnalyzer searchAnalyzer,
SimilarityProvider similarity, float boost, Map<String, String> meta) {
super(name, fieldType.indexOptions() != IndexOptions.NONE,
super(name, fieldType.indexOptions() != IndexOptions.NONE, fieldType.stored(),
hasDocValues, new TextSearchInfo(fieldType, similarity, searchAnalyzer, searchAnalyzer), meta);
this.hasNorms = fieldType.omitNorms() == false;
setEagerGlobalOrdinals(eagerGlobalOrdinals);
@ -217,7 +217,7 @@ public final class KeywordFieldMapper extends ParametrizedFieldMapper {
}
public KeywordFieldType(String name, boolean isSearchable, boolean hasDocValues, Map<String, String> meta) {
super(name, isSearchable, hasDocValues, TextSearchInfo.SIMPLE_MATCH_ONLY, meta);
super(name, isSearchable, false, hasDocValues, TextSearchInfo.SIMPLE_MATCH_ONLY, meta);
setIndexAnalyzer(Lucene.KEYWORD_ANALYZER);
}
@ -227,7 +227,7 @@ public final class KeywordFieldMapper extends ParametrizedFieldMapper {
}
public KeywordFieldType(String name, NamedAnalyzer analyzer) {
super(name, true, true, new TextSearchInfo(Defaults.FIELD_TYPE, null, analyzer, analyzer), Collections.emptyMap());
super(name, true, false, true, new TextSearchInfo(Defaults.FIELD_TYPE, null, analyzer, analyzer), Collections.emptyMap());
}
@Override

View File

@ -257,7 +257,7 @@ public class LegacyGeoShapeFieldMapper extends AbstractShapeGeometryFieldMapper<
}
private GeoShapeFieldType buildFieldType(BuilderContext context) {
GeoShapeFieldType ft = new GeoShapeFieldType(buildFullName(context), indexed, false, meta);
GeoShapeFieldType ft = new GeoShapeFieldType(buildFullName(context), indexed, fieldType.stored(), false, meta);
setupFieldTypeDeprecatedParameters(context, ft);
setupPrefixTrees(ft);
ft.setGeometryIndexer(new LegacyGeoShapeIndexer(ft));
@ -324,12 +324,12 @@ public class LegacyGeoShapeFieldMapper extends AbstractShapeGeometryFieldMapper<
private RecursivePrefixTreeStrategy recursiveStrategy;
private TermQueryPrefixTreeStrategy termStrategy;
public GeoShapeFieldType(String name, boolean indexed, boolean hasDocValues, Map<String, String> meta) {
super(name, indexed, hasDocValues, meta);
public GeoShapeFieldType(String name, boolean indexed, boolean stored, boolean hasDocValues, Map<String, String> meta) {
super(name, indexed, stored, hasDocValues, meta);
}
public GeoShapeFieldType(String name) {
this(name, true, true, Collections.emptyMap());
this(name, true, false, true, Collections.emptyMap());
}
@Override

View File

@ -66,16 +66,19 @@ public abstract class MappedFieldType {
private final String name;
private final boolean docValues;
private final boolean isIndexed;
private final boolean isStored;
private final TextSearchInfo textSearchInfo;
private final Map<String, String> meta;
private float boost;
private NamedAnalyzer indexAnalyzer;
private boolean eagerGlobalOrdinals;
public MappedFieldType(String name, boolean isIndexed, boolean hasDocValues, TextSearchInfo textSearchInfo, Map<String, String> meta) {
public MappedFieldType(String name, boolean isIndexed, boolean isStored,
boolean hasDocValues, TextSearchInfo textSearchInfo, Map<String, String> meta) {
setBoost(1.0f);
this.name = Objects.requireNonNull(name);
this.isIndexed = isIndexed;
this.isStored = isStored;
this.docValues = hasDocValues;
this.textSearchInfo = Objects.requireNonNull(textSearchInfo);
this.meta = meta;
@ -140,6 +143,13 @@ public abstract class MappedFieldType {
return isIndexed;
}
/**
* Returns true if the field is stored separately.
*/
public boolean isStored() {
return isStored;
}
/**
* If the field supports using the indexed data to speed up operations related to ordering of data, such as sorting or aggs, return
* a function for doing that. If it is unsupported for this field type, there is no need to override this method.
@ -176,13 +186,13 @@ public abstract class MappedFieldType {
*/
// TODO: Standardize exception types
public abstract Query termQuery(Object value, @Nullable QueryShardContext context);
// Case insensitive form of term query (not supported by all fields so must be overridden to enable)
public Query termQueryCaseInsensitive(Object value, @Nullable QueryShardContext context) {
throw new QueryShardException(context, "[" + name + "] field which is of type [" + typeName() +
throw new QueryShardException(context, "[" + name + "] field which is of type [" + typeName() +
"], does not support case insensitive term queries");
}
}
/** Build a constant-scoring query that matches all values. The default implementation uses a
* {@link ConstantScoreQuery} around a {@link BooleanQuery} whose {@link Occur#SHOULD} clauses
@ -216,9 +226,9 @@ public abstract class MappedFieldType {
// Case sensitive form of prefix query
public final Query prefixQuery(String value, @Nullable MultiTermQuery.RewriteMethod method, QueryShardContext context) {
return prefixQuery(value, method, false, context);
}
public Query prefixQuery(String value, @Nullable MultiTermQuery.RewriteMethod method, boolean caseInsensitve,
}
public Query prefixQuery(String value, @Nullable MultiTermQuery.RewriteMethod method, boolean caseInsensitve,
QueryShardContext context) {
throw new QueryShardException(context, "Can only use prefix queries on keyword, text and wildcard fields - not on [" + name
+ "] which is of type [" + typeName() + "]");
@ -230,7 +240,7 @@ public abstract class MappedFieldType {
) {
return wildcardQuery(value, method, false, context);
}
public Query wildcardQuery(String value,
@Nullable MultiTermQuery.RewriteMethod method,
boolean caseInsensitve, QueryShardContext context) {
@ -287,7 +297,7 @@ public abstract class MappedFieldType {
public enum Relation {
WITHIN,
INTERSECTS,
DISJOINT;
DISJOINT
}
/** Return whether all values of the given {@link IndexReader} are within the range,

View File

@ -21,7 +21,6 @@ package org.elasticsearch.index.mapper;
import com.fasterxml.jackson.core.JsonParseException;
import com.fasterxml.jackson.core.exc.InputCoercionException;
import org.apache.lucene.document.DoublePoint;
import org.apache.lucene.document.Field;
import org.apache.lucene.document.FloatPoint;
@ -132,8 +131,8 @@ public class NumberFieldMapper extends ParametrizedFieldMapper {
@Override
public NumberFieldMapper build(BuilderContext context) {
return new NumberFieldMapper(name,
new NumberFieldType(buildFullName(context), type, indexed.getValue(), hasDocValues.getValue(), meta.getValue()),
multiFieldsBuilder.build(this, context), copyTo.build(), this);
new NumberFieldType(buildFullName(context), type, indexed.getValue(), stored.getValue(), hasDocValues.getValue(),
meta.getValue()), multiFieldsBuilder.build(this, context), copyTo.build(), this);
}
}
@ -898,14 +897,15 @@ public class NumberFieldMapper extends ParametrizedFieldMapper {
private final NumberType type;
public NumberFieldType(String name, NumberType type, boolean isSearchable, boolean hasDocValues, Map<String, String> meta) {
super(name, isSearchable, hasDocValues, TextSearchInfo.SIMPLE_MATCH_ONLY, meta);
public NumberFieldType(String name, NumberType type, boolean isSearchable, boolean isStored,
boolean hasDocValues, Map<String, String> meta) {
super(name, isSearchable, isStored, hasDocValues, TextSearchInfo.SIMPLE_MATCH_ONLY, meta);
this.type = Objects.requireNonNull(type);
this.setIndexAnalyzer(Lucene.KEYWORD_ANALYZER); // allows number fields in significant text aggs - do we need this?
}
public NumberFieldType(String name, NumberType type) {
this(name, type, true, true, Collections.emptyMap());
this(name, type, true, false, true, Collections.emptyMap());
}
@Override

View File

@ -139,14 +139,15 @@ public class RangeFieldMapper extends ParametrizedFieldMapper {
} else {
dateTimeFormatter = DateFormatter.forPattern(format.getValue()).withLocale(locale.getValue());
}
return new RangeFieldType(buildFullName(context), index.getValue(), hasDocValues.getValue(),
return new RangeFieldType(buildFullName(context), index.getValue(), store.getValue(), hasDocValues.getValue(),
dateTimeFormatter, meta.getValue());
}
}
if (type == RangeType.DATE) {
return new RangeFieldType(buildFullName(context), index.getValue(), hasDocValues.getValue(),
return new RangeFieldType(buildFullName(context), index.getValue(), store.getValue(), hasDocValues.getValue(),
Defaults.DATE_FORMATTER, meta.getValue());
}
return new RangeFieldType(buildFullName(context), type, index.getValue(), hasDocValues.getValue(), meta.getValue());
return new RangeFieldType(buildFullName(context), type, index.getValue(), store.getValue(), hasDocValues.getValue(),
meta.getValue());
}
@Override
@ -162,8 +163,9 @@ public class RangeFieldMapper extends ParametrizedFieldMapper {
protected final DateFormatter dateTimeFormatter;
protected final DateMathParser dateMathParser;
public RangeFieldType(String name, RangeType type, boolean indexed, boolean hasDocValues, Map<String, String> meta) {
super(name, indexed, hasDocValues, TextSearchInfo.SIMPLE_MATCH_ONLY, meta);
public RangeFieldType(String name, RangeType type, boolean indexed, boolean stored,
boolean hasDocValues, Map<String, String> meta) {
super(name, indexed, stored, hasDocValues, TextSearchInfo.SIMPLE_MATCH_ONLY, meta);
assert type != RangeType.DATE;
this.rangeType = Objects.requireNonNull(type);
dateTimeFormatter = null;
@ -172,11 +174,12 @@ public class RangeFieldMapper extends ParametrizedFieldMapper {
}
public RangeFieldType(String name, RangeType type) {
this(name, type, true, true, Collections.emptyMap());
this(name, type, true, false, true, Collections.emptyMap());
}
public RangeFieldType(String name, boolean indexed, boolean hasDocValues, DateFormatter formatter, Map<String, String> meta) {
super(name, indexed, hasDocValues, TextSearchInfo.SIMPLE_MATCH_ONLY, meta);
public RangeFieldType(String name, boolean indexed, boolean stored, boolean hasDocValues, DateFormatter formatter,
Map<String, String> meta) {
super(name, indexed, stored, hasDocValues, TextSearchInfo.SIMPLE_MATCH_ONLY, meta);
this.rangeType = RangeType.DATE;
this.dateTimeFormatter = Objects.requireNonNull(formatter);
this.dateMathParser = dateTimeFormatter.toDateMathParser();
@ -184,7 +187,7 @@ public class RangeFieldMapper extends ParametrizedFieldMapper {
}
public RangeFieldType(String name, DateFormatter formatter) {
this(name, true, true, formatter, Collections.emptyMap());
this(name, true, false, true, formatter, Collections.emptyMap());
}
public RangeType rangeType() { return rangeType; }

View File

@ -28,7 +28,6 @@ import org.apache.lucene.search.TermQuery;
import org.elasticsearch.common.lucene.Lucene;
import org.elasticsearch.index.query.QueryShardContext;
import java.io.IOException;
import java.util.Collections;
import java.util.List;
@ -89,7 +88,7 @@ public class RoutingFieldMapper extends MetadataFieldMapper {
static RoutingFieldType INSTANCE = new RoutingFieldType();
private RoutingFieldType() {
super(NAME, true, false, TextSearchInfo.SIMPLE_MATCH_ONLY, Collections.emptyMap());
super(NAME, true, true, false, TextSearchInfo.SIMPLE_MATCH_ONLY, Collections.emptyMap());
setIndexAnalyzer(Lucene.KEYWORD_ANALYZER);
}
@ -116,7 +115,7 @@ public class RoutingFieldMapper extends MetadataFieldMapper {
}
@Override
public void preParse(ParseContext context) throws IOException {
public void preParse(ParseContext context) {
String routing = context.sourceToParse().routing();
if (routing != null) {
context.doc().add(new Field(fieldType().name(), routing, Defaults.FIELD_TYPE));

View File

@ -98,7 +98,7 @@ public class SeqNoFieldMapper extends MetadataFieldMapper {
private static final SeqNoFieldType INSTANCE = new SeqNoFieldType();
SeqNoFieldType() {
super(NAME, true, true, TextSearchInfo.SIMPLE_MATCH_ONLY, Collections.emptyMap());
super(NAME, true, false, true, TextSearchInfo.SIMPLE_MATCH_ONLY, Collections.emptyMap());
}
@Override
@ -174,7 +174,6 @@ public class SeqNoFieldMapper extends MetadataFieldMapper {
failIfNoDocValues();
return new SortedNumericIndexFieldData.Builder(name(), NumericType.LONG);
}
}
public SeqNoFieldMapper() {

View File

@ -32,9 +32,9 @@ import java.util.Map;
*/
public abstract class SimpleMappedFieldType extends MappedFieldType {
protected SimpleMappedFieldType(String name, boolean isSearchable, boolean hasDocValues,
protected SimpleMappedFieldType(String name, boolean isSearchable, boolean isStored, boolean hasDocValues,
TextSearchInfo textSearchInfo, Map<String, String> meta) {
super(name, isSearchable, hasDocValues, textSearchInfo, meta);
super(name, isSearchable, isStored, hasDocValues, textSearchInfo, meta);
}
@Override

View File

@ -66,7 +66,6 @@ public class SourceFieldMapper extends MetadataFieldMapper {
FIELD_TYPE.setOmitNorms(true);
FIELD_TYPE.freeze();
}
}
private static SourceFieldMapper toType(FieldMapper in) {
@ -102,10 +101,8 @@ public class SourceFieldMapper extends MetadataFieldMapper {
static final class SourceFieldType extends MappedFieldType {
public static final SourceFieldType INSTANCE = new SourceFieldType();
private SourceFieldType() {
super(NAME, false, false, TextSearchInfo.NONE, Collections.emptyMap());
private SourceFieldType(boolean enabled) {
super(NAME, false, enabled, false, TextSearchInfo.NONE, Collections.emptyMap());
}
@Override
@ -125,7 +122,6 @@ public class SourceFieldMapper extends MetadataFieldMapper {
}
private final boolean enabled;
/** indicates whether the source will always exist and be complete, for use by features like the update API */
private final boolean complete;
@ -137,7 +133,7 @@ public class SourceFieldMapper extends MetadataFieldMapper {
}
private SourceFieldMapper(boolean enabled, String[] includes, String[] excludes) {
super(SourceFieldType.INSTANCE); // Only stored.
super(new SourceFieldType(enabled));
this.enabled = enabled;
this.includes = includes;
this.excludes = excludes;

View File

@ -52,9 +52,9 @@ public abstract class StringFieldType extends TermBasedFieldType {
private static final Pattern WILDCARD_PATTERN = Pattern.compile("(\\\\.)|([?*]+)");
public StringFieldType(String name, boolean isSearchable, boolean hasDocValues,
public StringFieldType(String name, boolean isSearchable, boolean isStored, boolean hasDocValues,
TextSearchInfo textSearchInfo, Map<String, String> meta) {
super(name, isSearchable, hasDocValues, textSearchInfo, meta);
super(name, isSearchable, isStored, hasDocValues, textSearchInfo, meta);
}
@Override
@ -83,7 +83,7 @@ public abstract class StringFieldType extends TermBasedFieldType {
query.setRewriteMethod(method);
}
return query;
}
PrefixQuery query = new PrefixQuery(new Term(name(), indexedValueForSearch(value)));
if (method != null) {
@ -140,7 +140,7 @@ public abstract class StringFieldType extends TermBasedFieldType {
if (caseInsensitive) {
AutomatonQuery query = AutomatonQueries.caseInsensitiveWildcardQuery(term);
QueryParsers.setRewriteMethod(query, method);
return query;
return query;
}
WildcardQuery query = new WildcardQuery(term);
QueryParsers.setRewriteMethod(query, method);

View File

@ -36,9 +36,9 @@ import java.util.Map;
* with the inverted index. */
public abstract class TermBasedFieldType extends SimpleMappedFieldType {
public TermBasedFieldType(String name, boolean isSearchable, boolean hasDocValues, TextSearchInfo textSearchInfo,
Map<String, String> meta) {
super(name, isSearchable, hasDocValues, textSearchInfo, meta);
public TermBasedFieldType(String name, boolean isSearchable, boolean isStored, boolean hasDocValues,
TextSearchInfo textSearchInfo, Map<String, String> meta) {
super(name, isSearchable, isStored, hasDocValues, textSearchInfo, meta);
}
/** Returns the indexed value used to construct search "values".
@ -55,7 +55,7 @@ public abstract class TermBasedFieldType extends SimpleMappedFieldType {
if (boost() != 1f) {
query = new BoostQuery(query, boost());
}
return query;
return query;
}
@Override

View File

@ -381,7 +381,7 @@ public class TextFieldMapper extends FieldMapper {
final TextFieldType parent;
PhraseFieldType(TextFieldType parent) {
super(parent.name() + FAST_PHRASE_SUFFIX, true, false, parent.getTextSearchInfo(), Collections.emptyMap());
super(parent.name() + FAST_PHRASE_SUFFIX, true, false, false, parent.getTextSearchInfo(), Collections.emptyMap());
setAnalyzer(parent.indexAnalyzer().name(), parent.indexAnalyzer().analyzer());
this.parent = parent;
}
@ -409,7 +409,7 @@ public class TextFieldMapper extends FieldMapper {
final boolean hasPositions;
PrefixFieldType(TextFieldType parentField, String name, int minChars, int maxChars, boolean hasPositions) {
super(name, true, false, parentField.getTextSearchInfo(), Collections.emptyMap());
super(name, true, false, false, parentField.getTextSearchInfo(), Collections.emptyMap());
this.minChars = minChars;
this.maxChars = maxChars;
this.parentField = parentField;
@ -453,7 +453,7 @@ public class TextFieldMapper extends FieldMapper {
} else {
automata.add(Automata.makeString(value));
}
for (int i = value.length(); i < minChars; i++) {
automata.add(Automata.makeAnyChar());
}
@ -575,7 +575,7 @@ public class TextFieldMapper extends FieldMapper {
public TextFieldType(String name, FieldType indexedFieldType, SimilarityProvider similarity, NamedAnalyzer searchAnalyzer,
NamedAnalyzer searchQuoteAnalyzer, Map<String, String> meta) {
super(name, indexedFieldType.indexOptions() != IndexOptions.NONE, false,
super(name, indexedFieldType.indexOptions() != IndexOptions.NONE, indexedFieldType.stored(), false,
new TextSearchInfo(indexedFieldType, similarity, searchAnalyzer, searchQuoteAnalyzer), meta);
this.indexedFieldType = indexedFieldType;
fielddata = false;
@ -584,8 +584,8 @@ public class TextFieldMapper extends FieldMapper {
fielddataMinSegmentSize = Defaults.FIELDDATA_MIN_SEGMENT_SIZE;
}
public TextFieldType(String name, boolean indexed, Map<String, String> meta) {
super(name, indexed, false,
public TextFieldType(String name, boolean indexed, boolean stored, Map<String, String> meta) {
super(name, indexed, stored, false,
new TextSearchInfo(Defaults.FIELD_TYPE, null, Lucene.STANDARD_ANALYZER, Lucene.STANDARD_ANALYZER), meta);
this.indexedFieldType = Defaults.FIELD_TYPE;
fielddata = false;

View File

@ -39,8 +39,6 @@ public class TextSearchInfo {
/**
* Defines indexing information for fields that support only simple match text queries
*
* Note that the results of {@link #isStored()} for this may not be accurate
*/
public static final TextSearchInfo SIMPLE_MATCH_ONLY
= new TextSearchInfo(SIMPLE_MATCH_ONLY_FIELD_TYPE, null, Lucene.KEYWORD_ANALYZER, Lucene.KEYWORD_ANALYZER);
@ -48,8 +46,6 @@ public class TextSearchInfo {
/**
* Defines indexing information for fields that index as keywords, but split query input
* on whitespace to build disjunctions.
*
* Note that the results of {@link #isStored()} for this may not be accurate
*/
public static final TextSearchInfo WHITESPACE_MATCH_ONLY
= new TextSearchInfo(SIMPLE_MATCH_ONLY_FIELD_TYPE, null, Lucene.WHITESPACE_ANALYZER, Lucene.WHITESPACE_ANALYZER);
@ -120,13 +116,6 @@ public class TextSearchInfo {
return luceneFieldType.tokenized();
}
/**
* @return whether or not this field is stored
*/
public boolean isStored() {
return luceneFieldType.stored(); // TODO move this directly to MappedFieldType? It's not text specific...
}
/**
* What sort of term vectors are available
*/

View File

@ -85,7 +85,7 @@ public class TypeFieldMapper extends MetadataFieldMapper {
public static final TypeFieldType INSTANCE = new TypeFieldType();
private TypeFieldType() {
super(NAME, true, false, TextSearchInfo.SIMPLE_MATCH_ONLY, Collections.emptyMap());
super(NAME, true, false, false, TextSearchInfo.SIMPLE_MATCH_ONLY, Collections.emptyMap());
}
@Override
@ -173,9 +173,9 @@ public class TypeFieldMapper extends MetadataFieldMapper {
if (caseInsensitive) {
AutomatonQuery query = AutomatonQueries.caseInsensitiveWildcardQuery(term);
QueryParsers.setRewriteMethod(query, method);
return query;
return query;
}
WildcardQuery query = new WildcardQuery(term);
QueryParsers.setRewriteMethod(query, method);
return query;

View File

@ -27,7 +27,6 @@ import org.elasticsearch.index.mapper.ParseContext.Document;
import org.elasticsearch.index.query.QueryShardContext;
import org.elasticsearch.index.query.QueryShardException;
import java.io.IOException;
import java.util.Collections;
/** Mapper for the _version field. */
@ -43,7 +42,7 @@ public class VersionFieldMapper extends MetadataFieldMapper {
public static final VersionFieldType INSTANCE = new VersionFieldType();
private VersionFieldType() {
super(NAME, false, true, TextSearchInfo.SIMPLE_MATCH_ONLY, Collections.emptyMap());
super(NAME, false, false, true, TextSearchInfo.SIMPLE_MATCH_ONLY, Collections.emptyMap());
}
@Override
@ -67,7 +66,7 @@ public class VersionFieldMapper extends MetadataFieldMapper {
}
@Override
public void preParse(ParseContext context) throws IOException {
public void preParse(ParseContext context) {
// see InternalEngine.updateVersion to see where the real version value is set
final Field version = new NumericDocValuesField(NAME, -1L);
context.version(version);
@ -75,7 +74,7 @@ public class VersionFieldMapper extends MetadataFieldMapper {
}
@Override
public void postParse(ParseContext context) throws IOException {
public void postParse(ParseContext context) {
// In the case of nested docs, let's fill nested docs with version=1 so that Lucene doesn't write a Bitset for documents
// that don't have the field. This is consistent with the default value for efficiency.
Field version = context.version();
@ -89,5 +88,4 @@ public class VersionFieldMapper extends MetadataFieldMapper {
protected String contentType() {
return CONTENT_TYPE;
}
}

View File

@ -78,7 +78,6 @@ public class FastVectorHighlighter implements Highlighter {
"] should be indexed with term vector with position offsets to be used with fast vector highlighter");
}
TextSearchInfo tsi = fieldType.getTextSearchInfo();
Encoder encoder = field.fieldOptions().encoder().equals("html") ?
HighlightUtils.Encoders.HTML : HighlightUtils.Encoders.DEFAULT;
@ -95,7 +94,7 @@ public class FastVectorHighlighter implements Highlighter {
if (field.fieldOptions().numberOfFragments() == 0) {
fragListBuilder = new SingleFragListBuilder();
if (!forceSource && tsi.isStored()) {
if (!forceSource && fieldType.isStored()) {
fragmentsBuilder = new SimpleFragmentsBuilder(fieldType, field.fieldOptions().preTags(),
field.fieldOptions().postTags(), boundaryScanner);
} else {
@ -106,7 +105,7 @@ public class FastVectorHighlighter implements Highlighter {
fragListBuilder = field.fieldOptions().fragmentOffset() == -1 ?
new SimpleFragListBuilder() : new SimpleFragListBuilder(field.fieldOptions().fragmentOffset());
if (field.fieldOptions().scoreOrdered()) {
if (!forceSource && tsi.isStored()) {
if (!forceSource && fieldType.isStored()) {
fragmentsBuilder = new ScoreOrderFragmentsBuilder(field.fieldOptions().preTags(),
field.fieldOptions().postTags(), boundaryScanner);
} else {
@ -114,7 +113,7 @@ public class FastVectorHighlighter implements Highlighter {
field.fieldOptions().preTags(), field.fieldOptions().postTags(), boundaryScanner);
}
} else {
if (!forceSource && tsi.isStored()) {
if (!forceSource && fieldType.isStored()) {
fragmentsBuilder = new SimpleFragmentsBuilder(fieldType, field.fieldOptions().preTags(),
field.fieldOptions().postTags(), boundaryScanner);
} else {

View File

@ -23,7 +23,6 @@ import org.apache.lucene.search.highlight.Encoder;
import org.apache.lucene.search.highlight.SimpleHTMLEncoder;
import org.elasticsearch.index.fieldvisitor.CustomFieldsVisitor;
import org.elasticsearch.index.mapper.MappedFieldType;
import org.elasticsearch.index.mapper.TextSearchInfo;
import org.elasticsearch.search.fetch.FetchSubPhase;
import org.elasticsearch.search.lookup.SourceLookup;
@ -51,8 +50,7 @@ public final class HighlightUtils {
boolean forceSource) throws IOException {
//percolator needs to always load from source, thus it sets the global force source to true
List<Object> textsToHighlight;
TextSearchInfo tsi = fieldType.getTextSearchInfo();
if (forceSource == false && tsi.isStored()) {
if (forceSource == false && fieldType.isStored()) {
CustomFieldsVisitor fieldVisitor = new CustomFieldsVisitor(singleton(fieldType.name()), false);
hitContext.reader().document(hitContext.docId(), fieldVisitor);
textsToHighlight = fieldVisitor.fields().get(fieldType.name());

View File

@ -1585,7 +1585,7 @@ public class MetadataIndexTemplateServiceTests extends ESSingleNodeTestCase {
final boolean enabled;
public MetadataTimestampFieldMapper(boolean enabled) {
super(new MappedFieldType("_data_stream_timestamp", false, false, TextSearchInfo.NONE, Collections.emptyMap()) {
super(new MappedFieldType("_data_stream_timestamp", false, false, false, TextSearchInfo.NONE, Collections.emptyMap()) {
@Override
public String typeName() {
return "_data_stream_timestamp";

View File

@ -312,17 +312,17 @@ public class IndexFieldDataServiceTests extends ESSingleNodeTestCase {
public void testRequireDocValuesOnLongs() {
doTestRequireDocValues(new NumberFieldMapper.NumberFieldType("field", NumberFieldMapper.NumberType.LONG));
doTestRequireDocValues(new NumberFieldMapper.NumberFieldType("field", NumberFieldMapper.NumberType.LONG,
true, false, Collections.emptyMap()));
true, false, false, Collections.emptyMap()));
}
public void testRequireDocValuesOnDoubles() {
doTestRequireDocValues(new NumberFieldMapper.NumberFieldType("field", NumberFieldMapper.NumberType.DOUBLE));
doTestRequireDocValues(new NumberFieldMapper.NumberFieldType("field", NumberFieldMapper.NumberType.DOUBLE,
true, false, Collections.emptyMap()));
true, false, false, Collections.emptyMap()));
}
public void testRequireDocValuesOnBools() {
doTestRequireDocValues(new BooleanFieldMapper.BooleanFieldType("field"));
doTestRequireDocValues(new BooleanFieldMapper.BooleanFieldType("field", true, false, Collections.emptyMap()));
doTestRequireDocValues(new BooleanFieldMapper.BooleanFieldType("field", true, false, false, Collections.emptyMap()));
}
}

View File

@ -45,7 +45,7 @@ public class BooleanFieldTypeTests extends FieldTypeTestCase {
assertEquals(new TermQuery(new Term("field", "T")), ft.termQuery("true", null));
assertEquals(new TermQuery(new Term("field", "F")), ft.termQuery("false", null));
MappedFieldType unsearchable = new BooleanFieldMapper.BooleanFieldType("field", false, true, Collections.emptyMap());
MappedFieldType unsearchable = new BooleanFieldMapper.BooleanFieldType("field", false, false, true, Collections.emptyMap());
IllegalArgumentException e = expectThrows(IllegalArgumentException.class,
() -> unsearchable.termQuery("true", null));
assertEquals("Cannot search on field [field] since it is not indexed.", e.getMessage());

View File

@ -262,8 +262,7 @@ public class DateFieldMapperTests extends MapperTestCase {
.field("format", "yyyy/MM/dd")));
assertThat(mapperService.fieldType("field"), notNullValue());
assertFalse(mapperService.fieldType("field")
.getTextSearchInfo().isStored());
assertFalse(mapperService.fieldType("field").isStored());
Exception e = expectThrows(IllegalArgumentException.class,
() -> merge(mapperService, fieldMapping(b -> b.field("type", "date").field("format", "epoch_millis"))));

View File

@ -70,13 +70,13 @@ public class DateFieldTypeTests extends FieldTypeTestCase {
}
public void testIsFieldWithinQueryDateMillis() throws IOException {
DateFieldType ft = new DateFieldType("my_date", true, true,
DateFieldType ft = new DateFieldType("my_date", true, false, true,
DateFieldMapper.DEFAULT_DATE_TIME_FORMATTER, Resolution.MILLISECONDS, Collections.emptyMap());
isFieldWithinRangeTestCase(ft);
}
public void testIsFieldWithinQueryDateNanos() throws IOException {
DateFieldType ft = new DateFieldType("my_date", true, true,
DateFieldType ft = new DateFieldType("my_date", true, false, true,
DateFieldMapper.DEFAULT_DATE_TIME_FORMATTER, Resolution.NANOSECONDS, Collections.emptyMap());
isFieldWithinRangeTestCase(ft);
}
@ -175,7 +175,7 @@ public class DateFieldTypeTests extends FieldTypeTestCase {
SortedNumericDocValuesField.newSlowRangeQuery("field", instant, instant + 999));
assertEquals(expected, ft.termQuery(date, context));
MappedFieldType unsearchable = new DateFieldType("field", false, true, DateFieldMapper.DEFAULT_DATE_TIME_FORMATTER,
MappedFieldType unsearchable = new DateFieldType("field", false, false, true, DateFieldMapper.DEFAULT_DATE_TIME_FORMATTER,
Resolution.MILLISECONDS, Collections.emptyMap());
IllegalArgumentException e = expectThrows(IllegalArgumentException.class,
() -> unsearchable.termQuery(date, context));
@ -210,7 +210,7 @@ public class DateFieldTypeTests extends FieldTypeTestCase {
assertEquals(expected,
ft.rangeQuery("now", instant2, true, true, null, null, null, context));
MappedFieldType unsearchable = new DateFieldType("field", false, true, DateFieldMapper.DEFAULT_DATE_TIME_FORMATTER,
MappedFieldType unsearchable = new DateFieldType("field", false, false, true, DateFieldMapper.DEFAULT_DATE_TIME_FORMATTER,
Resolution.MILLISECONDS, Collections.emptyMap());
IllegalArgumentException e = expectThrows(IllegalArgumentException.class,
() -> unsearchable.rangeQuery(date1, date2, true, true, null, null, null, context));

View File

@ -74,7 +74,7 @@ public class DocumentFieldMapperTests extends LuceneTestCase {
static class FakeFieldType extends TermBasedFieldType {
FakeFieldType(String name) {
super(name, true, true, TextSearchInfo.SIMPLE_MATCH_ONLY, Collections.emptyMap());
super(name, true, false, true, TextSearchInfo.SIMPLE_MATCH_ONLY, Collections.emptyMap());
}
@Override

View File

@ -116,9 +116,8 @@ public class ExternalMapper extends FieldMapper {
this.generatedValue = generatedValue;
}
@SuppressWarnings({"unchecked"})
@Override
public Mapper.Builder parse(String name, Map<String, Object> node, ParserContext parserContext) throws MapperParsingException {
public Mapper.Builder<?> parse(String name, Map<String, Object> node, ParserContext parserContext) throws MapperParsingException {
ExternalMapper.Builder builder = new ExternalMapper.Builder(name, generatedValue, mapperName);
parseField(builder, name, node, parserContext);
return builder;
@ -127,8 +126,8 @@ public class ExternalMapper extends FieldMapper {
static class ExternalFieldType extends TermBasedFieldType {
ExternalFieldType(String name, boolean indexed, boolean hasDocValues) {
super(name, indexed, hasDocValues, TextSearchInfo.SIMPLE_MATCH_ONLY, Collections.emptyMap());
ExternalFieldType(String name, boolean indexed, boolean stored, boolean hasDocValues) {
super(name, indexed, stored, hasDocValues, TextSearchInfo.SIMPLE_MATCH_ONLY, Collections.emptyMap());
}
@Override
@ -160,7 +159,7 @@ public class ExternalMapper extends FieldMapper {
BinaryFieldMapper binMapper, BooleanFieldMapper boolMapper, GeoPointFieldMapper pointMapper,
AbstractShapeGeometryFieldMapper shapeMapper, FieldMapper stringMapper,
MultiFields multiFields, CopyTo copyTo, boolean indexed) {
super(simpleName, fieldType, new ExternalFieldType(contextName, indexed, false), multiFields, copyTo);
super(simpleName, fieldType, new ExternalFieldType(contextName, indexed, fieldType.stored(), false), multiFields, copyTo);
this.generatedValue = generatedValue;
this.mapperName = mapperName;
this.binMapper = binMapper;

View File

@ -66,7 +66,8 @@ public class FakeStringFieldMapper extends FieldMapper {
public FakeStringFieldMapper build(BuilderContext context) {
return new FakeStringFieldMapper(
fieldType,
new FakeStringFieldType(name, new TextSearchInfo(fieldType, null, Lucene.STANDARD_ANALYZER, Lucene.STANDARD_ANALYZER)),
new FakeStringFieldType(name, fieldType.stored(),
new TextSearchInfo(fieldType, null, Lucene.STANDARD_ANALYZER, Lucene.STANDARD_ANALYZER)),
multiFieldsBuilder.build(this, context), copyTo);
}
}
@ -77,7 +78,8 @@ public class FakeStringFieldMapper extends FieldMapper {
}
@Override
public Mapper.Builder parse(String fieldName, Map<String, Object> node, ParserContext parserContext) throws MapperParsingException {
public Mapper.Builder<?> parse(String fieldName, Map<String, Object> node,
ParserContext parserContext) throws MapperParsingException {
FakeStringFieldMapper.Builder builder = new FakeStringFieldMapper.Builder(fieldName);
parseTextField(builder, fieldName, node, parserContext);
return builder;
@ -86,9 +88,8 @@ public class FakeStringFieldMapper extends FieldMapper {
public static final class FakeStringFieldType extends StringFieldType {
public FakeStringFieldType(String name, TextSearchInfo textSearchInfo) {
super(name, true, true, textSearchInfo, Collections.emptyMap());
public FakeStringFieldType(String name, boolean stored, TextSearchInfo textSearchInfo) {
super(name, true, stored, true, textSearchInfo, Collections.emptyMap());
setIndexAnalyzer(Lucene.STANDARD_ANALYZER);
}

View File

@ -50,7 +50,7 @@ public class GenericStoreDynamicTemplateTests extends ESSingleNodeTestCase {
assertThat(f.stringValue(), equalTo("some name"));
assertThat(f.fieldType().stored(), equalTo(true));
assertTrue(mapperService.fieldType("name").getTextSearchInfo().isStored());
assertTrue(mapperService.fieldType("name").isStored());
boolean stored = false;
for (IndexableField field : doc.getFields("age")) {

View File

@ -71,7 +71,7 @@ public class IpFieldTypeTests extends FieldTypeTestCase {
prefix = ip + "/16";
assertEquals(InetAddressPoint.newPrefixQuery("field", InetAddresses.forString(ip), 16), ft.termQuery(prefix, null));
MappedFieldType unsearchable = new IpFieldMapper.IpFieldType("field", false, true, Collections.emptyMap());
MappedFieldType unsearchable = new IpFieldMapper.IpFieldType("field", false, false, true, Collections.emptyMap());
IllegalArgumentException e = expectThrows(IllegalArgumentException.class,
() -> unsearchable.termQuery("::1", null));
assertEquals("Cannot search on field [field] since it is not indexed.", e.getMessage());
@ -174,7 +174,7 @@ public class IpFieldTypeTests extends FieldTypeTestCase {
InetAddresses.forString("2001:db8::")),
ft.rangeQuery("::ffff:c0a8:107", "2001:db8::", true, true, null, null, null, null));
MappedFieldType unsearchable = new IpFieldMapper.IpFieldType("field", false, true, Collections.emptyMap());
MappedFieldType unsearchable = new IpFieldMapper.IpFieldType("field", false, false, true, Collections.emptyMap());
IllegalArgumentException e = expectThrows(IllegalArgumentException.class,
() -> unsearchable.rangeQuery("::1", "2001::", true, true, null, null, null, null));
assertEquals("Cannot search on field [field] since it is not indexed.", e.getMessage());

View File

@ -94,25 +94,25 @@ public class MultiFieldTests extends ESSingleNodeTestCase {
assertThat(mapperService.fieldType("name"), notNullValue());
assertThat(mapperService.fieldType("name"), instanceOf(TextFieldType.class));
assertTrue(mapperService.fieldType("name").isSearchable());
assertTrue(mapperService.fieldType("name").getTextSearchInfo().isStored());
assertTrue(mapperService.fieldType("name").isStored());
assertTrue(mapperService.fieldType("name").getTextSearchInfo().isTokenized());
assertThat(mapperService.fieldType("name.indexed"), notNullValue());
assertThat(mapperService.fieldType("name"), instanceOf(TextFieldType.class));
assertTrue(mapperService.fieldType("name.indexed").isSearchable());
assertFalse(mapperService.fieldType("name.indexed").getTextSearchInfo().isStored());
assertFalse(mapperService.fieldType("name.indexed").isStored());
assertTrue(mapperService.fieldType("name.indexed").getTextSearchInfo().isTokenized());
assertThat(mapperService.fieldType("name.not_indexed"), notNullValue());
assertThat(mapperService.fieldType("name"), instanceOf(TextFieldType.class));
assertFalse(mapperService.fieldType("name.not_indexed").isSearchable());
assertTrue(mapperService.fieldType("name.not_indexed").getTextSearchInfo().isStored());
assertTrue(mapperService.fieldType("name.not_indexed").isStored());
assertTrue(mapperService.fieldType("name.not_indexed").getTextSearchInfo().isTokenized());
assertThat(mapperService.fieldType("name.test1"), notNullValue());
assertThat(mapperService.fieldType("name"), instanceOf(TextFieldType.class));
assertTrue(mapperService.fieldType("name.test1").isSearchable());
assertTrue(mapperService.fieldType("name.test1").getTextSearchInfo().isStored());
assertTrue(mapperService.fieldType("name.test1").isStored());
assertTrue(mapperService.fieldType("name.test1").getTextSearchInfo().isTokenized());
assertThat(mapperService.fieldType("name.test1").eagerGlobalOrdinals(), equalTo(true));

View File

@ -136,7 +136,7 @@ public class NumberFieldTypeTests extends FieldTypeTestCase {
assertEquals(LongPoint.newExactQuery("field", 42), ft.termQuery("42", null));
MappedFieldType unsearchable
= new NumberFieldType("field", NumberType.LONG, false, true, Collections.emptyMap());
= new NumberFieldType("field", NumberType.LONG, false, false, true, Collections.emptyMap());
IllegalArgumentException e = expectThrows(IllegalArgumentException.class,
() -> unsearchable.termQuery("42", null));
assertEquals("Cannot search on field [field] since it is not indexed.", e.getMessage());
@ -253,7 +253,7 @@ public class NumberFieldTypeTests extends FieldTypeTestCase {
SortedNumericDocValuesField.newSlowRangeQuery("field", 1, 3));
assertEquals(expected, ft.rangeQuery("1", "3", true, true, null, null, null, MOCK_QSC));
MappedFieldType unsearchable = new NumberFieldType("field", NumberType.LONG, false, true, Collections.emptyMap());
MappedFieldType unsearchable = new NumberFieldType("field", NumberType.LONG, false, false, true, Collections.emptyMap());
IllegalArgumentException e = expectThrows(IllegalArgumentException.class,
() -> unsearchable.rangeQuery("1", "3", true, true, null, null, null, MOCK_QSC));
assertEquals("Cannot search on field [field] since it is not indexed.", e.getMessage());

View File

@ -50,19 +50,19 @@ public class PathMatchDynamicTemplateTests extends ESSingleNodeTestCase {
assertThat(f.stringValue(), equalTo("top_level"));
assertThat(f.fieldType().stored(), equalTo(false));
assertThat(mapperService.fieldType("name").getTextSearchInfo().isStored(), equalTo(false));
assertThat(mapperService.fieldType("name").isStored(), equalTo(false));
f = doc.getField("obj1.name");
assertThat(f.name(), equalTo("obj1.name"));
assertThat(f.fieldType().stored(), equalTo(true));
assertThat(mapperService.fieldType("obj1.name").getTextSearchInfo().isStored(), equalTo(true));
assertThat(mapperService.fieldType("obj1.name").isStored(), equalTo(true));
f = doc.getField("obj1.obj2.name");
assertThat(f.name(), equalTo("obj1.obj2.name"));
assertThat(f.fieldType().stored(), equalTo(false));
assertThat(mapperService.fieldType("obj1.obj2.name").getTextSearchInfo().isStored(), equalTo(false));
assertThat(mapperService.fieldType("obj1.obj2.name").isStored(), equalTo(false));
// verify more complex path_match expressions
assertNotNull(mapperService.fieldType("obj3.obj4.prop1").getTextSearchInfo());

View File

@ -66,9 +66,9 @@ public class RangeFieldTypeTests extends FieldTypeTestCase {
private RangeFieldType createDefaultFieldType() {
if (type == RangeType.DATE) {
return new RangeFieldType("field", true, true, RangeFieldMapper.Defaults.DATE_FORMATTER, Collections.emptyMap());
return new RangeFieldType("field", true, false, true, RangeFieldMapper.Defaults.DATE_FORMATTER, Collections.emptyMap());
}
return new RangeFieldType("field", type, true, true, Collections.emptyMap());
return new RangeFieldType("field", type, true, false, true, Collections.emptyMap());
}
public void testRangeQuery() throws Exception {
@ -217,7 +217,7 @@ public class RangeFieldTypeTests extends FieldTypeTestCase {
public void testDateRangeQueryUsingMappingFormat() {
QueryShardContext context = createContext();
RangeFieldType strict
= new RangeFieldType("field", true, false, RangeFieldMapper.Defaults.DATE_FORMATTER, Collections.emptyMap());
= new RangeFieldType("field", true, false, false, RangeFieldMapper.Defaults.DATE_FORMATTER, Collections.emptyMap());
// don't use DISJOINT here because it doesn't work on date fields which we want to compare bounds with
ShapeRelation relation = randomValueOtherThan(ShapeRelation.DISJOINT,() -> randomFrom(ShapeRelation.values()));
@ -236,13 +236,13 @@ public class RangeFieldTypeTests extends FieldTypeTestCase {
assertEquals(1465975790000L, formatter.parseMillis(from));
assertEquals(1466062190000L, formatter.parseMillis(to));
RangeFieldType fieldType = new RangeFieldType("field", true, true, formatter, Collections.emptyMap());
RangeFieldType fieldType = new RangeFieldType("field", true, false, true, formatter, Collections.emptyMap());
final Query query = fieldType.rangeQuery(from, to, true, true, relation, null, fieldType.dateMathParser(), context);
assertEquals("field:<ranges:[1465975790000 : 1466062190999]>", query.toString());
// compare lower and upper bounds with what we would get on a `date` field
DateFieldType dateFieldType
= new DateFieldType("field", true, true, formatter, DateFieldMapper.Resolution.MILLISECONDS, Collections.emptyMap());
= new DateFieldType("field", true, false, true, formatter, DateFieldMapper.Resolution.MILLISECONDS, Collections.emptyMap());
final Query queryOnDateField = dateFieldType.rangeQuery(from, to, true, true, relation, null, fieldType.dateMathParser(), context);
assertEquals("field:[1465975790000 TO 1466062190999]", queryOnDateField.toString());
}
@ -259,7 +259,7 @@ public class RangeFieldTypeTests extends FieldTypeTestCase {
long lower = randomLongBetween(formatter.parseMillis("2000-01-01T00:00"), formatter.parseMillis("2010-01-01T00:00"));
long upper = randomLongBetween(formatter.parseMillis("2011-01-01T00:00"), formatter.parseMillis("2020-01-01T00:00"));
RangeFieldType fieldType = new RangeFieldType("field", true, false, formatter, Collections.emptyMap());
RangeFieldType fieldType = new RangeFieldType("field", true, false, false, formatter, Collections.emptyMap());
String lowerAsString = formatter.formatMillis(lower);
String upperAsString = formatter.formatMillis(upper);
// also add date math rounding to days occasionally

View File

@ -66,7 +66,7 @@ public class TextFieldTypeTests extends FieldTypeTestCase {
assertEquals(new TermQuery(new Term("field", "foo")), ft.termQuery("foo", null));
assertEquals(AutomatonQueries.caseInsensitiveTermQuery(new Term("field", "fOo")), ft.termQueryCaseInsensitive("fOo", null));
MappedFieldType unsearchable = new TextFieldType("field", false, Collections.emptyMap());
MappedFieldType unsearchable = new TextFieldType("field", false, false, Collections.emptyMap());
IllegalArgumentException e = expectThrows(IllegalArgumentException.class,
() -> unsearchable.termQuery("bar", null));
assertEquals("Cannot search on field [field] since it is not indexed.", e.getMessage());
@ -80,7 +80,7 @@ public class TextFieldTypeTests extends FieldTypeTestCase {
assertEquals(new TermInSetQuery("field", terms),
ft.termsQuery(Arrays.asList("foo", "bar"), null));
MappedFieldType unsearchable = new TextFieldType("field", false, Collections.emptyMap());
MappedFieldType unsearchable = new TextFieldType("field", false, false, Collections.emptyMap());
IllegalArgumentException e = expectThrows(IllegalArgumentException.class,
() -> unsearchable.termsQuery(Arrays.asList("foo", "bar"), null));
assertEquals("Cannot search on field [field] since it is not indexed.", e.getMessage());
@ -102,7 +102,7 @@ public class TextFieldTypeTests extends FieldTypeTestCase {
assertEquals(new RegexpQuery(new Term("field","foo.*")),
ft.regexpQuery("foo.*", 0, 0, 10, null, MOCK_QSC));
MappedFieldType unsearchable = new TextFieldType("field", false, Collections.emptyMap());
MappedFieldType unsearchable = new TextFieldType("field", false, false, Collections.emptyMap());
IllegalArgumentException e = expectThrows(IllegalArgumentException.class,
() -> unsearchable.regexpQuery("foo.*", 0, 0, 10, null, MOCK_QSC));
assertEquals("Cannot search on field [field] since it is not indexed.", e.getMessage());
@ -118,7 +118,7 @@ public class TextFieldTypeTests extends FieldTypeTestCase {
assertEquals(new FuzzyQuery(new Term("field","foo"), 2, 1, 50, true),
ft.fuzzyQuery("foo", Fuzziness.fromEdits(2), 1, 50, true, MOCK_QSC));
MappedFieldType unsearchable = new TextFieldType("field", false, Collections.emptyMap());
MappedFieldType unsearchable = new TextFieldType("field", false, false, Collections.emptyMap());
IllegalArgumentException e = expectThrows(IllegalArgumentException.class,
() -> unsearchable.fuzzyQuery("foo", Fuzziness.fromEdits(2), 1, 50, true, MOCK_QSC));
assertEquals("Cannot search on field [field] since it is not indexed.", e.getMessage());
@ -142,8 +142,8 @@ public class TextFieldTypeTests extends FieldTypeTestCase {
q = ft.prefixQuery("Internationalisatio", CONSTANT_SCORE_REWRITE, true, MOCK_QSC);
assertEquals(AutomatonQueries.caseInsensitivePrefixQuery(new Term("field", "Internationalisatio")), q);
ElasticsearchException ee = expectThrows(ElasticsearchException.class,
() -> ft.prefixQuery("internationalisatio", null, false, MOCK_QSC_DISALLOW_EXPENSIVE));
assertEquals("[prefix] queries cannot be executed when 'search.allow_expensive_queries' is set to false. " +

View File

@ -98,7 +98,7 @@ public class AggregatorBaseTests extends ESSingleNodeTestCase {
boolean indexed,
QueryShardContext context
) {
MappedFieldType ft = new NumberFieldMapper.NumberFieldType(fieldName, numType, indexed, true, Collections.emptyMap());
MappedFieldType ft = new NumberFieldMapper.NumberFieldType(fieldName, numType, indexed, false, true, Collections.emptyMap());
return ValuesSourceConfig.resolveFieldOnly(ft, context);
}
@ -108,7 +108,7 @@ public class AggregatorBaseTests extends ESSingleNodeTestCase {
boolean indexed,
QueryShardContext context
) {
MappedFieldType ft = new DateFieldMapper.DateFieldType(fieldName, indexed, true,
MappedFieldType ft = new DateFieldMapper.DateFieldType(fieldName, indexed, false, true,
DateFieldMapper.DEFAULT_DATE_TIME_FORMATTER, resolution, Collections.emptyMap());
return ValuesSourceConfig.resolveFieldOnly(ft, context);
}

View File

@ -96,7 +96,7 @@ public abstract class DateHistogramAggregatorTestCase extends AggregatorTestCase
}
protected final DateFieldMapper.DateFieldType aggregableDateFieldType(boolean useNanosecondResolution, boolean isSearchable) {
return new DateFieldMapper.DateFieldType(AGGREGABLE_DATE, isSearchable, true,
return new DateFieldMapper.DateFieldType(AGGREGABLE_DATE, isSearchable, false, true,
DateFieldMapper.DEFAULT_DATE_TIME_FORMATTER,
useNanosecondResolution ? DateFieldMapper.Resolution.NANOSECONDS : DateFieldMapper.Resolution.MILLISECONDS,
Collections.emptyMap());

View File

@ -271,7 +271,7 @@ public class DateRangeAggregatorTests extends AggregatorTestCase {
CheckedConsumer<RandomIndexWriter, IOException> buildIndex,
Consumer<InternalRange<? extends InternalRange.Bucket, ? extends InternalRange>> verify,
DateFieldMapper.Resolution resolution) throws IOException {
DateFieldMapper.DateFieldType fieldType = new DateFieldMapper.DateFieldType(DATE_FIELD_NAME, true, true,
DateFieldMapper.DateFieldType fieldType = new DateFieldMapper.DateFieldType(DATE_FIELD_NAME, true, false, true,
DateFieldMapper.DEFAULT_DATE_TIME_FORMATTER, resolution, Collections.emptyMap());
DateRangeAggregationBuilder aggregationBuilder = new DateRangeAggregationBuilder("test_range_agg");
aggregationBuilder.field(DATE_FIELD_NAME);

View File

@ -119,7 +119,7 @@ public class RangeAggregatorTests extends AggregatorTestCase {
@AwaitsFix(bugUrl="https://github.com/elastic/elasticsearch/issues/57651")
public void testDateFieldNanosecondResolution() throws IOException {
DateFieldMapper.DateFieldType fieldType = new DateFieldMapper.DateFieldType(DATE_FIELD_NAME, true, true,
DateFieldMapper.DateFieldType fieldType = new DateFieldMapper.DateFieldType(DATE_FIELD_NAME, true, false, true,
DateFieldMapper.DEFAULT_DATE_TIME_FORMATTER, DateFieldMapper.Resolution.NANOSECONDS, Collections.emptyMap());
// These values should work because aggs scale nanosecond up to millisecond always.
@ -143,7 +143,7 @@ public class RangeAggregatorTests extends AggregatorTestCase {
@AwaitsFix(bugUrl="https://github.com/elastic/elasticsearch/issues/57651")
public void testMissingDateWithDateField() throws IOException {
DateFieldMapper.DateFieldType fieldType = new DateFieldMapper.DateFieldType(DATE_FIELD_NAME, true, true,
DateFieldMapper.DateFieldType fieldType = new DateFieldMapper.DateFieldType(DATE_FIELD_NAME, true, false, true,
DateFieldMapper.DEFAULT_DATE_TIME_FORMATTER, DateFieldMapper.Resolution.NANOSECONDS, Collections.emptyMap());
// These values should work because aggs scale nanosecond up to millisecond always.

View File

@ -154,13 +154,15 @@ public class CollapseBuilderTests extends AbstractSerializingTestCase<CollapseBu
assertEquals(collapseContext.getFieldType(), numberFieldType);
numberFieldType =
new NumberFieldMapper.NumberFieldType("field", NumberFieldMapper.NumberType.LONG, true, false, Collections.emptyMap());
new NumberFieldMapper.NumberFieldType("field", NumberFieldMapper.NumberType.LONG, true, false,
false, Collections.emptyMap());
when(shardContext.fieldMapper("field")).thenReturn(numberFieldType);
IllegalArgumentException exc = expectThrows(IllegalArgumentException.class, () -> builder.build(shardContext));
assertEquals(exc.getMessage(), "cannot collapse on field `field` without `doc_values`");
numberFieldType =
new NumberFieldMapper.NumberFieldType("field", NumberFieldMapper.NumberType.LONG, false, true, Collections.emptyMap());
new NumberFieldMapper.NumberFieldType("field", NumberFieldMapper.NumberType.LONG, false, false,
true, Collections.emptyMap());
when(shardContext.fieldMapper("field")).thenReturn(numberFieldType);
builder.setInnerHits(new InnerHitBuilder());
exc = expectThrows(IllegalArgumentException.class, () -> builder.build(shardContext));
@ -197,7 +199,7 @@ public class CollapseBuilderTests extends AbstractSerializingTestCase<CollapseBu
}
{
MappedFieldType fieldType = new MappedFieldType("field", true, true, TextSearchInfo.NONE, Collections.emptyMap()) {
MappedFieldType fieldType = new MappedFieldType("field", true, false, true, TextSearchInfo.NONE, Collections.emptyMap()) {
@Override
public String typeName() {
return null;

View File

@ -119,7 +119,8 @@ public class SliceBuilderTests extends ESTestCase {
private QueryShardContext createShardContext(Version indexVersionCreated, IndexReader reader,
String fieldName, DocValuesType dvType, int numShards, int shardId) {
MappedFieldType fieldType = new MappedFieldType(fieldName, true, dvType != null, TextSearchInfo.NONE, Collections.emptyMap()) {
MappedFieldType fieldType = new MappedFieldType(fieldName, true, false, dvType != null,
TextSearchInfo.NONE, Collections.emptyMap()) {
@Override
public String typeName() {

View File

@ -63,7 +63,7 @@ public class MockFieldMapper extends FieldMapper {
public static class FakeFieldType extends TermBasedFieldType {
public FakeFieldType(String name) {
super(name, true, false, TextSearchInfo.SIMPLE_MATCH_ONLY, Collections.emptyMap());
super(name, true, false, false, TextSearchInfo.SIMPLE_MATCH_ONLY, Collections.emptyMap());
}
@Override

View File

@ -183,7 +183,7 @@ public class HistogramFieldMapper extends FieldMapper {
public static class HistogramFieldType extends MappedFieldType {
public HistogramFieldType(String name, boolean hasDocValues, Map<String, String> meta) {
super(name, false, hasDocValues, TextSearchInfo.SIMPLE_MATCH_ONLY, meta);
super(name, false, false, hasDocValues, TextSearchInfo.SIMPLE_MATCH_ONLY, meta);
}
@Override

View File

@ -428,6 +428,7 @@ public class RateAggregatorTests extends AggregatorTestCase {
return new DateFieldMapper.DateFieldType(
name,
true,
false,
true,
DateFieldMapper.DEFAULT_DATE_TIME_FORMATTER,
DateFieldMapper.Resolution.MILLISECONDS,

View File

@ -14,10 +14,10 @@ import org.elasticsearch.common.xcontent.XContentBuilder;
import org.elasticsearch.common.xcontent.XContentHelper;
import org.elasticsearch.common.xcontent.XContentType;
import org.elasticsearch.index.mapper.DateFieldMapper;
import org.elasticsearch.index.mapper.MappingLookup;
import org.elasticsearch.index.mapper.FieldMapper;
import org.elasticsearch.index.mapper.MappedFieldType;
import org.elasticsearch.index.mapper.Mapper;
import org.elasticsearch.index.mapper.MappingLookup;
import org.elasticsearch.index.mapper.MetadataFieldMapper;
import org.elasticsearch.index.mapper.ParametrizedFieldMapper;
import org.elasticsearch.index.mapper.ParseContext;
@ -43,7 +43,7 @@ public class DataStreamTimestampFieldMapper extends MetadataFieldMapper {
public static final class TimestampFieldType extends MappedFieldType {
public TimestampFieldType() {
super(NAME, false, false, TextSearchInfo.NONE, Collections.emptyMap());
super(NAME, false, false, false, TextSearchInfo.NONE, Collections.emptyMap());
}
@Override
@ -60,7 +60,6 @@ public class DataStreamTimestampFieldMapper extends MetadataFieldMapper {
public Query existsQuery(QueryShardContext context) {
throw new IllegalArgumentException("Field [" + name() + "] of type [" + typeName() + "] does not support exists queries");
}
}
private static DataStreamTimestampFieldMapper toType(FieldMapper in) {

View File

@ -232,7 +232,7 @@ public final class FlatObjectFieldMapper extends DynamicKeyFieldMapper {
public KeyedFlatObjectFieldType(String name, boolean indexed, boolean hasDocValues, String key,
boolean splitQueriesOnWhitespace, Map<String, String> meta) {
super(name, indexed, hasDocValues,
super(name, indexed, false, hasDocValues,
splitQueriesOnWhitespace ? TextSearchInfo.WHITESPACE_MATCH_ONLY : TextSearchInfo.SIMPLE_MATCH_ONLY,
meta);
setIndexAnalyzer(Lucene.KEYWORD_ANALYZER);
@ -299,8 +299,6 @@ public final class FlatObjectFieldMapper extends DynamicKeyFieldMapper {
throw new UnsupportedOperationException("[wildcard] queries are not currently supported on keyed " +
"[" + CONTENT_TYPE + "] fields.");
}
@Override
public Query termQueryCaseInsensitive(Object value, QueryShardContext context) {
@ -310,7 +308,7 @@ public final class FlatObjectFieldMapper extends DynamicKeyFieldMapper {
}
return query;
}
@Override
public BytesRef indexedValueForSearch(Object value) {
if (value == null) {
@ -329,7 +327,6 @@ public final class FlatObjectFieldMapper extends DynamicKeyFieldMapper {
failIfNoDocValues();
return new KeyedFlatObjectFieldData.Builder(name(), key, CoreValuesSourceType.BYTES);
}
}
/**
@ -446,7 +443,7 @@ public final class FlatObjectFieldMapper extends DynamicKeyFieldMapper {
public RootFlatObjectFieldType(String name, boolean indexed, boolean hasDocValues, Map<String, String> meta,
boolean splitQueriesOnWhitespace) {
super(name, indexed, hasDocValues,
super(name, indexed, false, hasDocValues,
splitQueriesOnWhitespace ? TextSearchInfo.WHITESPACE_MATCH_ONLY : TextSearchInfo.SIMPLE_MATCH_ONLY, meta);
this.splitQueriesOnWhitespace = splitQueriesOnWhitespace;
setIndexAnalyzer(Lucene.KEYWORD_ANALYZER);
@ -480,7 +477,6 @@ public final class FlatObjectFieldMapper extends DynamicKeyFieldMapper {
failIfNoDocValues();
return new SortedSetOrdinalsIndexFieldData.Builder(name(), CoreValuesSourceType.BYTES);
}
}
private FlatObjectFieldParser fieldParser;

View File

@ -43,7 +43,7 @@ abstract class AbstractScriptMappedFieldType<LeafFactory> extends MappedFieldTyp
TriFunction<String, Map<String, Object>, SearchLookup, LeafFactory> factory,
Map<String, String> meta
) {
super(name, false, false, TextSearchInfo.SIMPLE_MATCH_ONLY, meta);
super(name, false, false, false, TextSearchInfo.SIMPLE_MATCH_ONLY, meta);
this.script = script;
this.factory = factory;
}

View File

@ -89,7 +89,8 @@ public class GeoShapeWithDocValuesFieldMapper extends GeoShapeFieldMapper {
if (docValuesSet == false) {
hasDocValues = Version.V_7_8_0.onOrBefore(context.indexCreatedVersion());
}
GeoShapeWithDocValuesFieldType ft = new GeoShapeWithDocValuesFieldType(buildFullName(context), indexed, hasDocValues, meta);
GeoShapeWithDocValuesFieldType ft = new GeoShapeWithDocValuesFieldType(buildFullName(context), indexed, fieldType.stored(),
hasDocValues, meta);
// @todo check coerce
GeometryParser geometryParser = new GeometryParser(ft.orientation().getAsBoolean(), coerce().value(),
ignoreZValue().value());
@ -129,8 +130,9 @@ public class GeoShapeWithDocValuesFieldMapper extends GeoShapeFieldMapper {
}
public static final class GeoShapeWithDocValuesFieldType extends GeoShapeFieldMapper.GeoShapeFieldType {
public GeoShapeWithDocValuesFieldType(String name, boolean indexed, boolean hasDocValues, Map<String, String> meta) {
super(name, indexed, hasDocValues, meta);
public GeoShapeWithDocValuesFieldType(String name, boolean indexed, boolean stored, boolean hasDocValues,
Map<String, String> meta) {
super(name, indexed, stored, hasDocValues, meta);
}
public IndexFieldData.Builder fielddataBuilder(String fullyQualifiedIndexName, Supplier<SearchLookup> searchLookup) {

View File

@ -44,7 +44,7 @@ public class PointFieldMapper extends AbstractPointGeometryFieldMapper<List<Pars
public PointFieldMapper build(BuilderContext context, String simpleName, FieldType fieldType,
MultiFields multiFields, Explicit<Boolean> ignoreMalformed,
Explicit<Boolean> ignoreZValue, ParsedPoint nullValue, CopyTo copyTo) {
PointFieldType ft = new PointFieldType(buildFullName(context), indexed, hasDocValues, meta);
PointFieldType ft = new PointFieldType(buildFullName(context), indexed, fieldType.stored(), hasDocValues, meta);
ft.setGeometryParser(new PointParser<>());
ft.setGeometryIndexer(new PointIndexer(ft));
ft.setGeometryQueryBuilder(new ShapeQueryPointProcessor());
@ -127,8 +127,8 @@ public class PointFieldMapper extends AbstractPointGeometryFieldMapper<List<Pars
}
public static class PointFieldType extends AbstractPointGeometryFieldType<List<ParsedCartesianPoint>, List<? extends CartesianPoint>> {
public PointFieldType(String name, boolean indexed, boolean hasDocValues, Map<String, String> meta) {
super(name, indexed, hasDocValues, meta);
public PointFieldType(String name, boolean indexed, boolean stored, boolean hasDocValues, Map<String, String> meta) {
super(name, indexed, stored, hasDocValues, meta);
}
@Override

View File

@ -51,7 +51,7 @@ public class ShapeFieldMapper extends AbstractShapeGeometryFieldMapper<Geometry,
@Override
public ShapeFieldMapper build(BuilderContext context) {
ShapeFieldType ft = new ShapeFieldType(buildFullName(context), indexed, hasDocValues, meta);
ShapeFieldType ft = new ShapeFieldType(buildFullName(context), indexed, fieldType.stored(), hasDocValues, meta);
GeometryParser geometryParser
= new GeometryParser(orientation().value().getAsBoolean(), coerce().value(), ignoreZValue().value());
ft.setGeometryParser(new GeoShapeParser(geometryParser));
@ -77,8 +77,8 @@ public class ShapeFieldMapper extends AbstractShapeGeometryFieldMapper<Geometry,
}
public static final class ShapeFieldType extends AbstractShapeGeometryFieldType<Geometry, Geometry> {
public ShapeFieldType(String name, boolean indexed, boolean hasDocValues, Map<String, String> meta) {
super(name, indexed, hasDocValues, meta);
public ShapeFieldType(String name, boolean indexed, boolean stored, boolean hasDocValues, Map<String, String> meta) {
super(name, indexed, stored, hasDocValues, meta);
}
@Override

View File

@ -63,7 +63,7 @@ public class GeoShapeCentroidAggregatorTests extends AggregatorTestCase {
.field("field");
MappedFieldType fieldType
= new GeoShapeWithDocValuesFieldMapper.GeoShapeWithDocValuesFieldType("field", true, true, Collections.emptyMap());
= new GeoShapeWithDocValuesFieldMapper.GeoShapeWithDocValuesFieldType("field", true, false, true, Collections.emptyMap());
try (IndexReader reader = w.getReader()) {
IndexSearcher searcher = new IndexSearcher(reader);
InternalGeoCentroid result = searchAndReduce(searcher, new MatchAllDocsQuery(), aggBuilder, fieldType);
@ -86,12 +86,12 @@ public class GeoShapeCentroidAggregatorTests extends AggregatorTestCase {
IndexSearcher searcher = new IndexSearcher(reader);
MappedFieldType fieldType = new GeoShapeWithDocValuesFieldMapper.GeoShapeWithDocValuesFieldType("another_field",
true, true, Collections.emptyMap());
true, false, true, Collections.emptyMap());
InternalGeoCentroid result = searchAndReduce(searcher, new MatchAllDocsQuery(), aggBuilder, fieldType);
assertNull(result.centroid());
fieldType = new GeoShapeWithDocValuesFieldMapper.GeoShapeWithDocValuesFieldType("field",
true, true, Collections.emptyMap());
true, false, true, Collections.emptyMap());
result = searchAndReduce(searcher, new MatchAllDocsQuery(), aggBuilder, fieldType);
assertNull(result.centroid());
assertFalse(AggregationInspectionHelper.hasValue(result));
@ -116,7 +116,7 @@ public class GeoShapeCentroidAggregatorTests extends AggregatorTestCase {
IndexSearcher searcher = new IndexSearcher(reader);
MappedFieldType fieldType = new GeoShapeWithDocValuesFieldMapper.GeoShapeWithDocValuesFieldType("another_field",
true, true, Collections.emptyMap());
true, false, true, Collections.emptyMap());
InternalGeoCentroid result = searchAndReduce(searcher, new MatchAllDocsQuery(), aggBuilder, fieldType);
assertThat(result.centroid(), equalTo(expectedCentroid));
assertTrue(AggregationInspectionHelper.hasValue(result));
@ -177,7 +177,7 @@ public class GeoShapeCentroidAggregatorTests extends AggregatorTestCase {
private void assertCentroid(RandomIndexWriter w, GeoPoint expectedCentroid) throws IOException {
MappedFieldType fieldType = new GeoShapeWithDocValuesFieldMapper.GeoShapeWithDocValuesFieldType("field",
true, true, Collections.emptyMap());
true, false, true, Collections.emptyMap());
GeoCentroidAggregationBuilder aggBuilder = new GeoCentroidAggregationBuilder("my_agg")
.field("field");
try (IndexReader reader = w.getReader()) {

View File

@ -27,7 +27,6 @@ import org.elasticsearch.geometry.Point;
import org.elasticsearch.geometry.Polygon;
import org.elasticsearch.geometry.utils.StandardValidator;
import org.elasticsearch.geometry.utils.WellKnownText;
import org.elasticsearch.xpack.spatial.index.mapper.GeoShapeWithDocValuesFieldMapper;
import org.elasticsearch.index.mapper.GeoShapeIndexer;
import org.elasticsearch.index.mapper.MappedFieldType;
import org.elasticsearch.index.query.QueryShardContext;
@ -36,6 +35,7 @@ import org.elasticsearch.ingest.IngestDocument;
import org.elasticsearch.ingest.RandomDocumentPicks;
import org.elasticsearch.test.ESTestCase;
import org.elasticsearch.xpack.spatial.SpatialUtils;
import org.elasticsearch.xpack.spatial.index.mapper.GeoShapeWithDocValuesFieldMapper;
import org.elasticsearch.xpack.spatial.index.mapper.ShapeFieldMapper;
import org.elasticsearch.xpack.spatial.index.mapper.ShapeIndexer;
import org.elasticsearch.xpack.spatial.index.query.ShapeQueryProcessor;
@ -214,7 +214,7 @@ public class CircleProcessorTests extends ESTestCase {
Geometry geometry = SpatialUtils.createRegularGeoShapePolygon(circle, numSides);
MappedFieldType shapeType
= new GeoShapeWithDocValuesFieldMapper.GeoShapeWithDocValuesFieldType(fieldName, true, false, Collections.emptyMap());
= new GeoShapeWithDocValuesFieldMapper.GeoShapeWithDocValuesFieldType(fieldName, true, false, false, Collections.emptyMap());
VectorGeoShapeQueryProcessor processor = new VectorGeoShapeQueryProcessor();
QueryShardContext mockedContext = mock(QueryShardContext.class);
@ -246,7 +246,7 @@ public class CircleProcessorTests extends ESTestCase {
int numSides = randomIntBetween(4, 1000);
Geometry geometry = SpatialUtils.createRegularShapePolygon(circle, numSides);
MappedFieldType shapeType = new ShapeFieldMapper.ShapeFieldType(fieldName, true, false, Collections.emptyMap());
MappedFieldType shapeType = new ShapeFieldMapper.ShapeFieldType(fieldName, true, false, false, Collections.emptyMap());
ShapeQueryProcessor processor = new ShapeQueryProcessor();
QueryShardContext mockedContext = mock(QueryShardContext.class);

View File

@ -300,7 +300,7 @@ public abstract class GeoShapeGeoGridTestCase<T extends InternalGeoGridBucket<T>
}
MappedFieldType fieldType
= new GeoShapeWithDocValuesFieldMapper.GeoShapeWithDocValuesFieldType(FIELD_NAME, true, true, Collections.emptyMap());
= new GeoShapeWithDocValuesFieldMapper.GeoShapeWithDocValuesFieldType(FIELD_NAME, true, false, true, Collections.emptyMap());
Aggregator aggregator = createAggregator(aggregationBuilder, indexSearcher, fieldType);
aggregator.preCollection();

View File

@ -58,7 +58,7 @@ public class GeoShapeBoundsAggregatorTests extends AggregatorTestCase {
.wrapLongitude(false);
MappedFieldType fieldType
= new GeoShapeWithDocValuesFieldMapper.GeoShapeWithDocValuesFieldType("field", true, true, Collections.emptyMap());
= new GeoShapeWithDocValuesFieldMapper.GeoShapeWithDocValuesFieldType("field", true, false, true, Collections.emptyMap());
try (IndexReader reader = w.getReader()) {
IndexSearcher searcher = new IndexSearcher(reader);
InternalGeoBounds bounds = searchAndReduce(searcher, new MatchAllDocsQuery(), aggBuilder, fieldType);
@ -86,7 +86,7 @@ public class GeoShapeBoundsAggregatorTests extends AggregatorTestCase {
.wrapLongitude(false);
MappedFieldType fieldType
= new GeoShapeWithDocValuesFieldMapper.GeoShapeWithDocValuesFieldType("field", true, true, Collections.emptyMap());
= new GeoShapeWithDocValuesFieldMapper.GeoShapeWithDocValuesFieldType("field", true, false, true, Collections.emptyMap());
try (IndexReader reader = w.getReader()) {
IndexSearcher searcher = new IndexSearcher(reader);
InternalGeoBounds bounds = searchAndReduce(searcher, new MatchAllDocsQuery(), aggBuilder, fieldType);
@ -108,7 +108,7 @@ public class GeoShapeBoundsAggregatorTests extends AggregatorTestCase {
w.addDocument(doc);
MappedFieldType fieldType
= new GeoShapeWithDocValuesFieldMapper.GeoShapeWithDocValuesFieldType("field", true, true, Collections.emptyMap());
= new GeoShapeWithDocValuesFieldMapper.GeoShapeWithDocValuesFieldType("field", true, false, true, Collections.emptyMap());
Point point = GeometryTestUtils.randomPoint(false);
double lon = GeoEncodingUtils.decodeLongitude(GeoEncodingUtils.encodeLongitude(point.getX()));
@ -140,7 +140,7 @@ public class GeoShapeBoundsAggregatorTests extends AggregatorTestCase {
w.addDocument(doc);
MappedFieldType fieldType
= new GeoShapeWithDocValuesFieldMapper.GeoShapeWithDocValuesFieldType("field", true, true, Collections.emptyMap());
= new GeoShapeWithDocValuesFieldMapper.GeoShapeWithDocValuesFieldType("field", true, false, true, Collections.emptyMap());
GeoBoundsAggregationBuilder aggBuilder = new GeoBoundsAggregationBuilder("my_agg")
.field("field")
@ -201,7 +201,7 @@ public class GeoShapeBoundsAggregatorTests extends AggregatorTestCase {
.wrapLongitude(false);
MappedFieldType fieldType
= new GeoShapeWithDocValuesFieldMapper.GeoShapeWithDocValuesFieldType("field", true, true, Collections.emptyMap());
= new GeoShapeWithDocValuesFieldMapper.GeoShapeWithDocValuesFieldType("field", true, false, true, Collections.emptyMap());
try (IndexReader reader = w.getReader()) {
IndexSearcher searcher = new IndexSearcher(reader);
InternalGeoBounds bounds = searchAndReduce(searcher, new MatchAllDocsQuery(), aggBuilder, fieldType);

View File

@ -105,7 +105,7 @@ public class DenseVectorFieldMapper extends FieldMapper {
private final int dims;
public DenseVectorFieldType(String name, int dims, Map<String, String> meta) {
super(name, false, true, TextSearchInfo.NONE, meta);
super(name, false, false, true, TextSearchInfo.NONE, meta);
this.dims = dims;
}

View File

@ -90,7 +90,7 @@ public class SparseVectorFieldMapper extends FieldMapper {
public static final class SparseVectorFieldType extends MappedFieldType {
public SparseVectorFieldType(String name, Map<String, String> meta) {
super(name, false, true, TextSearchInfo.NONE, meta);
super(name, false, false, true, TextSearchInfo.NONE, meta);
}
@Override

View File

@ -68,8 +68,8 @@ import static org.elasticsearch.xpack.versionfield.VersionEncoder.encodeVersion;
*/
public class VersionStringFieldMapper extends ParametrizedFieldMapper {
private static byte[] MIN_VALUE = new byte[16];
private static byte[] MAX_VALUE = new byte[16];
private static final byte[] MIN_VALUE = new byte[16];
private static final byte[] MAX_VALUE = new byte[16];
static {
Arrays.fill(MIN_VALUE, (byte) 0);
Arrays.fill(MAX_VALUE, (byte) -1);
@ -123,7 +123,7 @@ public class VersionStringFieldMapper extends ParametrizedFieldMapper {
public static final class VersionStringFieldType extends TermBasedFieldType {
public VersionStringFieldType(String name, FieldType fieldType, Map<String, String> meta) {
super(name, true, true, new TextSearchInfo(fieldType, null, Lucene.KEYWORD_ANALYZER, Lucene.KEYWORD_ANALYZER), meta);
super(name, true, false, true, new TextSearchInfo(fieldType, null, Lucene.KEYWORD_ANALYZER, Lucene.KEYWORD_ANALYZER), meta);
setIndexAnalyzer(Lucene.KEYWORD_ANALYZER);
}

View File

@ -213,7 +213,7 @@ public class WildcardFieldMapper extends FieldMapper {
static Analyzer lowercaseNormalizer = new LowercaseNormalizer();
public WildcardFieldType(String name, FieldType fieldType, Map<String, String> meta) {
super(name, true, true,
super(name, true, fieldType.stored(), true,
new TextSearchInfo(fieldType, null, Lucene.KEYWORD_ANALYZER, Lucene.KEYWORD_ANALYZER), meta);
setIndexAnalyzer(WILDCARD_ANALYZER);
}
@ -852,7 +852,7 @@ public class WildcardFieldMapper extends FieldMapper {
String searchTerm = BytesRefs.toString(value);
return wildcardQuery(escapeWildcardSyntax(searchTerm), MultiTermQuery.CONSTANT_SCORE_REWRITE, false, context);
}
private String escapeWildcardSyntax(String term) {
StringBuilder result = new StringBuilder();
for (int i = 0; i < term.length();) {
@ -867,12 +867,12 @@ public class WildcardFieldMapper extends FieldMapper {
}
return result.toString();
}
@Override
public Query termQueryCaseInsensitive(Object value, QueryShardContext context) {
String searchTerm = BytesRefs.toString(value);
return wildcardQuery(escapeWildcardSyntax(searchTerm), MultiTermQuery.CONSTANT_SCORE_REWRITE, true, context);
}
}
@Override
public Query prefixQuery(String value, MultiTermQuery.RewriteMethod method, boolean caseInsensitive, QueryShardContext context) {
@ -887,7 +887,7 @@ public class WildcardFieldMapper extends FieldMapper {
}
return new ConstantScoreQuery(bq.build());
}
@Override
public IndexFieldData.Builder fielddataBuilder(String fullyQualifiedIndexName, Supplier<SearchLookup> searchLookup) {
failIfNoDocValues();