Internal: Fix field mappers to always pass through index settings
Currently many meta field mappers do not take index settings in their simple constructor that DocumentMapper uses, and instead pass null or empty settings to the parent abstract mapper. This change fixes them to pass through index settings, and adds an assertion in AbstractFieldMapper that settings are not null. closes #9780
This commit is contained in:
parent
1e015e6e33
commit
f3d5d483db
|
@ -185,19 +185,19 @@ public class DocumentMapper implements ToXContent {
|
|||
this.rootObjectMapper = builder.build(builderContext);
|
||||
|
||||
// UID first so it will be the first stored field to load (so will benefit from "fields: []" early termination
|
||||
this.rootMappers.put(UidFieldMapper.class, new UidFieldMapper());
|
||||
this.rootMappers.put(UidFieldMapper.class, new UidFieldMapper(indexSettings));
|
||||
this.rootMappers.put(IdFieldMapper.class, new IdFieldMapper(indexSettings));
|
||||
this.rootMappers.put(RoutingFieldMapper.class, new RoutingFieldMapper(indexSettings));
|
||||
// add default mappers, order is important (for example analyzer should come before the rest to set context.analyzer)
|
||||
this.rootMappers.put(SizeFieldMapper.class, new SizeFieldMapper(indexSettings));
|
||||
this.rootMappers.put(IndexFieldMapper.class, new IndexFieldMapper());
|
||||
this.rootMappers.put(IndexFieldMapper.class, new IndexFieldMapper(indexSettings));
|
||||
this.rootMappers.put(SourceFieldMapper.class, new SourceFieldMapper(indexSettings));
|
||||
this.rootMappers.put(TypeFieldMapper.class, new TypeFieldMapper());
|
||||
this.rootMappers.put(AllFieldMapper.class, new AllFieldMapper());
|
||||
this.rootMappers.put(TypeFieldMapper.class, new TypeFieldMapper(indexSettings));
|
||||
this.rootMappers.put(AllFieldMapper.class, new AllFieldMapper(indexSettings));
|
||||
this.rootMappers.put(BoostFieldMapper.class, new BoostFieldMapper(indexSettings));
|
||||
this.rootMappers.put(TimestampFieldMapper.class, new TimestampFieldMapper(indexSettings));
|
||||
this.rootMappers.put(TTLFieldMapper.class, new TTLFieldMapper(indexSettings));
|
||||
this.rootMappers.put(VersionFieldMapper.class, new VersionFieldMapper());
|
||||
this.rootMappers.put(VersionFieldMapper.class, new VersionFieldMapper(indexSettings));
|
||||
this.rootMappers.put(ParentFieldMapper.class, new ParentFieldMapper(indexSettings));
|
||||
// _field_names last so that it can see all other fields
|
||||
this.rootMappers.put(FieldNamesFieldMapper.class, new FieldNamesFieldMapper(indexSettings));
|
||||
|
|
|
@ -314,6 +314,7 @@ public abstract class AbstractFieldMapper<T> implements FieldMapper<T> {
|
|||
protected AbstractFieldMapper(Names names, float boost, FieldType fieldType, Boolean docValues, NamedAnalyzer indexAnalyzer,
|
||||
NamedAnalyzer searchAnalyzer, SimilarityProvider similarity,
|
||||
Loading normsLoading, @Nullable Settings fieldDataSettings, Settings indexSettings, MultiFields multiFields, CopyTo copyTo) {
|
||||
assert indexSettings != null;
|
||||
this.names = names;
|
||||
this.boost = boost;
|
||||
this.fieldType = fieldType;
|
||||
|
@ -347,9 +348,7 @@ public abstract class AbstractFieldMapper<T> implements FieldMapper<T> {
|
|||
}
|
||||
this.multiFields = multiFields;
|
||||
this.copyTo = copyTo;
|
||||
// the short circuit check to EMPTY here is necessary because some built in fields pass EMPTY for simplified ctors
|
||||
this.writePre20Metadata = indexSettings != null && indexSettings.equals(ImmutableSettings.EMPTY) == false &&
|
||||
Version.indexCreated(indexSettings).before(Version.V_2_0_0);
|
||||
this.writePre20Metadata = Version.indexCreated(indexSettings).before(Version.V_2_0_0);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
|
|
|
@ -99,7 +99,7 @@ public class BinaryFieldMapper extends AbstractFieldMapper<BytesReference> {
|
|||
@Override
|
||||
public BinaryFieldMapper build(BuilderContext context) {
|
||||
return new BinaryFieldMapper(buildNames(context), fieldType, docValues, compress, compressThreshold,
|
||||
fieldDataSettings, multiFieldsBuilder.build(this, context), copyTo);
|
||||
fieldDataSettings, context.indexSettings(), multiFieldsBuilder.build(this, context), copyTo);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -135,8 +135,8 @@ public class BinaryFieldMapper extends AbstractFieldMapper<BytesReference> {
|
|||
private long compressThreshold;
|
||||
|
||||
protected BinaryFieldMapper(Names names, FieldType fieldType, Boolean docValues, Boolean compress, long compressThreshold,
|
||||
@Nullable Settings fieldDataSettings, MultiFields multiFields, CopyTo copyTo) {
|
||||
super(names, 1.0f, fieldType, docValues, null, null, null, null, fieldDataSettings, null, multiFields, copyTo);
|
||||
@Nullable Settings fieldDataSettings, Settings indexSettings, MultiFields multiFields, CopyTo copyTo) {
|
||||
super(names, 1.0f, fieldType, docValues, null, null, null, null, fieldDataSettings, indexSettings, multiFields, copyTo);
|
||||
this.compress = compress;
|
||||
this.compressThreshold = compressThreshold;
|
||||
}
|
||||
|
|
|
@ -21,7 +21,6 @@ package org.elasticsearch.index.mapper.core;
|
|||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Maps;
|
||||
import com.google.common.collect.Sets;
|
||||
|
||||
import org.apache.lucene.analysis.Analyzer;
|
||||
import org.apache.lucene.analysis.TokenStream;
|
||||
import org.apache.lucene.codecs.PostingsFormat;
|
||||
|
@ -34,6 +33,7 @@ import org.elasticsearch.ElasticsearchIllegalStateException;
|
|||
import org.elasticsearch.ElasticsearchParseException;
|
||||
import org.elasticsearch.Version;
|
||||
import org.elasticsearch.common.ParseField;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||
import org.elasticsearch.common.xcontent.XContentFactory;
|
||||
import org.elasticsearch.common.xcontent.XContentParser;
|
||||
|
@ -151,7 +151,7 @@ public class CompletionFieldMapper extends AbstractFieldMapper<String> {
|
|||
@Override
|
||||
public CompletionFieldMapper build(Mapper.BuilderContext context) {
|
||||
return new CompletionFieldMapper(buildNames(context), indexAnalyzer, searchAnalyzer, null, similarity, payloads,
|
||||
preserveSeparators, preservePositionIncrements, maxInputLength, multiFieldsBuilder.build(this, context), copyTo, this.contextMapping);
|
||||
preserveSeparators, preservePositionIncrements, maxInputLength, context.indexSettings(), multiFieldsBuilder.build(this, context), copyTo, this.contextMapping);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -239,8 +239,8 @@ public class CompletionFieldMapper extends AbstractFieldMapper<String> {
|
|||
// Custom postings formats are deprecated but we still accept a postings format here to be able to test backward compatibility
|
||||
// with older postings formats such as Elasticsearch090
|
||||
public CompletionFieldMapper(Names names, NamedAnalyzer indexAnalyzer, NamedAnalyzer searchAnalyzer, PostingsFormat wrappedPostingsFormat, SimilarityProvider similarity, boolean payloads,
|
||||
boolean preserveSeparators, boolean preservePositionIncrements, int maxInputLength, MultiFields multiFields, CopyTo copyTo, SortedMap<String, ContextMapping> contextMappings) {
|
||||
super(names, 1.0f, Defaults.FIELD_TYPE, null, indexAnalyzer, searchAnalyzer, similarity, null, null, null, multiFields, copyTo);
|
||||
boolean preserveSeparators, boolean preservePositionIncrements, int maxInputLength, Settings indexSettings, MultiFields multiFields, CopyTo copyTo, SortedMap<String, ContextMapping> contextMappings) {
|
||||
super(names, 1.0f, Defaults.FIELD_TYPE, null, indexAnalyzer, searchAnalyzer, similarity, null, null, indexSettings, multiFields, copyTo);
|
||||
analyzingSuggestLookupProvider = new AnalyzingCompletionLookupProvider(preserveSeparators, false, preservePositionIncrements, payloads);
|
||||
if (wrappedPostingsFormat == null) {
|
||||
// delayed until postingsFormat() is called
|
||||
|
|
|
@ -19,7 +19,6 @@
|
|||
package org.elasticsearch.index.mapper.geo;
|
||||
|
||||
import com.spatial4j.core.shape.Shape;
|
||||
|
||||
import org.apache.lucene.document.Field;
|
||||
import org.apache.lucene.document.FieldType;
|
||||
import org.apache.lucene.index.IndexOptions;
|
||||
|
@ -35,6 +34,7 @@ import org.elasticsearch.common.geo.GeoUtils;
|
|||
import org.elasticsearch.common.geo.SpatialStrategy;
|
||||
import org.elasticsearch.common.geo.builders.ShapeBuilder;
|
||||
import org.elasticsearch.common.geo.builders.ShapeBuilder.Orientation;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.common.unit.DistanceUnit;
|
||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||
import org.elasticsearch.index.fielddata.FieldDataType;
|
||||
|
@ -161,7 +161,7 @@ public class GeoShapeFieldMapper extends AbstractFieldMapper<String> {
|
|||
}
|
||||
|
||||
return new GeoShapeFieldMapper(names, prefixTree, strategyName, distanceErrorPct, orientation, fieldType,
|
||||
multiFieldsBuilder.build(this, context), copyTo);
|
||||
context.indexSettings(), multiFieldsBuilder.build(this, context), copyTo);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -214,8 +214,8 @@ public class GeoShapeFieldMapper extends AbstractFieldMapper<String> {
|
|||
private Orientation shapeOrientation;
|
||||
|
||||
public GeoShapeFieldMapper(FieldMapper.Names names, SpatialPrefixTree tree, String defaultStrategyName, double distanceErrorPct,
|
||||
Orientation shapeOrientation, FieldType fieldType, MultiFields multiFields, CopyTo copyTo) {
|
||||
super(names, 1, fieldType, null, null, null, null, null, null, null, multiFields, copyTo);
|
||||
Orientation shapeOrientation, FieldType fieldType, Settings indexSettings, MultiFields multiFields, CopyTo copyTo) {
|
||||
super(names, 1, fieldType, null, null, null, null, null, null, indexSettings, multiFields, copyTo);
|
||||
this.recursiveStrategy = new RecursivePrefixTreeStrategy(tree, names.indexName());
|
||||
this.recursiveStrategy.setDistErrPct(distanceErrorPct);
|
||||
this.termStrategy = new TermQueryPrefixTreeStrategy(tree, names.indexName());
|
||||
|
|
|
@ -151,8 +151,8 @@ public class AllFieldMapper extends AbstractFieldMapper<String> implements Inter
|
|||
// special SpanTermQuery to look at payloads
|
||||
private volatile boolean autoBoost;
|
||||
|
||||
public AllFieldMapper() {
|
||||
this(Defaults.NAME, new FieldType(Defaults.FIELD_TYPE), null, null, Defaults.ENABLED, false, null, null, null, ImmutableSettings.EMPTY);
|
||||
public AllFieldMapper(Settings indexSettings) {
|
||||
this(Defaults.NAME, new FieldType(Defaults.FIELD_TYPE), null, null, Defaults.ENABLED, false, null, null, null, indexSettings);
|
||||
}
|
||||
|
||||
protected AllFieldMapper(String name, FieldType fieldType, NamedAnalyzer indexAnalyzer, NamedAnalyzer searchAnalyzer,
|
||||
|
|
|
@ -59,7 +59,6 @@ public class IndexFieldMapper extends AbstractFieldMapper<String> implements Int
|
|||
|
||||
public static class Defaults extends AbstractFieldMapper.Defaults {
|
||||
public static final String NAME = IndexFieldMapper.NAME;
|
||||
public static final String INDEX_NAME = IndexFieldMapper.NAME;
|
||||
|
||||
public static final FieldType FIELD_TYPE = new FieldType(AbstractFieldMapper.Defaults.FIELD_TYPE);
|
||||
|
||||
|
@ -80,7 +79,7 @@ public class IndexFieldMapper extends AbstractFieldMapper<String> implements Int
|
|||
|
||||
public Builder() {
|
||||
super(Defaults.NAME, new FieldType(Defaults.FIELD_TYPE));
|
||||
indexName = Defaults.INDEX_NAME;
|
||||
indexName = Defaults.NAME;
|
||||
}
|
||||
|
||||
public Builder enabled(EnabledAttributeMapper enabledState) {
|
||||
|
@ -116,12 +115,8 @@ public class IndexFieldMapper extends AbstractFieldMapper<String> implements Int
|
|||
|
||||
private EnabledAttributeMapper enabledState;
|
||||
|
||||
public IndexFieldMapper() {
|
||||
this(Defaults.NAME, Defaults.INDEX_NAME);
|
||||
}
|
||||
|
||||
protected IndexFieldMapper(String name, String indexName) {
|
||||
this(name, indexName, Defaults.BOOST, new FieldType(Defaults.FIELD_TYPE), null, Defaults.ENABLED_STATE, null, ImmutableSettings.EMPTY);
|
||||
public IndexFieldMapper(Settings indexSettings) {
|
||||
this(Defaults.NAME, Defaults.NAME, Defaults.BOOST, new FieldType(Defaults.FIELD_TYPE), null, Defaults.ENABLED_STATE, null, indexSettings);
|
||||
}
|
||||
|
||||
public IndexFieldMapper(String name, String indexName, float boost, FieldType fieldType, Boolean docValues, EnabledAttributeMapper enabledState,
|
||||
|
|
|
@ -66,7 +66,6 @@ public class TypeFieldMapper extends AbstractFieldMapper<String> implements Inte
|
|||
|
||||
public static class Defaults extends AbstractFieldMapper.Defaults {
|
||||
public static final String NAME = TypeFieldMapper.NAME;
|
||||
public static final String INDEX_NAME = TypeFieldMapper.NAME;
|
||||
|
||||
public static final FieldType FIELD_TYPE = new FieldType(AbstractFieldMapper.Defaults.FIELD_TYPE);
|
||||
|
||||
|
@ -83,7 +82,7 @@ public class TypeFieldMapper extends AbstractFieldMapper<String> implements Inte
|
|||
|
||||
public Builder() {
|
||||
super(Defaults.NAME, new FieldType(Defaults.FIELD_TYPE));
|
||||
indexName = Defaults.INDEX_NAME;
|
||||
indexName = Defaults.NAME;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -101,13 +100,8 @@ public class TypeFieldMapper extends AbstractFieldMapper<String> implements Inte
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
public TypeFieldMapper() {
|
||||
this(Defaults.NAME, Defaults.INDEX_NAME);
|
||||
}
|
||||
|
||||
protected TypeFieldMapper(String name, String indexName) {
|
||||
this(name, indexName, Defaults.BOOST, new FieldType(Defaults.FIELD_TYPE), null, ImmutableSettings.EMPTY);
|
||||
public TypeFieldMapper(Settings indexSettings) {
|
||||
this(Defaults.NAME, Defaults.NAME, Defaults.BOOST, new FieldType(Defaults.FIELD_TYPE), null, indexSettings);
|
||||
}
|
||||
|
||||
public TypeFieldMapper(String name, String indexName, float boost, FieldType fieldType, @Nullable Settings fieldDataSettings, Settings indexSettings) {
|
||||
|
|
|
@ -101,12 +101,8 @@ public class UidFieldMapper extends AbstractFieldMapper<Uid> implements Internal
|
|||
}
|
||||
}
|
||||
|
||||
public UidFieldMapper() {
|
||||
this(Defaults.NAME);
|
||||
}
|
||||
|
||||
protected UidFieldMapper(String name) {
|
||||
this(name, name, null, null, ImmutableSettings.EMPTY);
|
||||
public UidFieldMapper(Settings indexSettings) {
|
||||
this(Defaults.NAME, Defaults.NAME, null, null, indexSettings);
|
||||
}
|
||||
|
||||
protected UidFieldMapper(String name, String indexName, Boolean docValues, @Nullable Settings fieldDataSettings, Settings indexSettings) {
|
||||
|
|
|
@ -25,6 +25,7 @@ import org.apache.lucene.document.NumericDocValuesField;
|
|||
import org.elasticsearch.Version;
|
||||
import org.elasticsearch.common.Strings;
|
||||
import org.elasticsearch.common.settings.ImmutableSettings;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||
import org.elasticsearch.index.fielddata.FieldDataType;
|
||||
import org.elasticsearch.index.mapper.InternalMapper;
|
||||
|
@ -66,7 +67,7 @@ public class VersionFieldMapper extends AbstractFieldMapper<Long> implements Int
|
|||
|
||||
@Override
|
||||
public VersionFieldMapper build(BuilderContext context) {
|
||||
return new VersionFieldMapper();
|
||||
return new VersionFieldMapper(context.indexSettings());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -94,8 +95,8 @@ public class VersionFieldMapper extends AbstractFieldMapper<Long> implements Int
|
|||
}
|
||||
};
|
||||
|
||||
public VersionFieldMapper() {
|
||||
super(new Names(NAME, NAME, NAME, NAME), Defaults.BOOST, Defaults.FIELD_TYPE, null, null, null, null, null, null, ImmutableSettings.EMPTY);
|
||||
public VersionFieldMapper(Settings indexSettings) {
|
||||
super(new Names(NAME, NAME, NAME, NAME), Defaults.BOOST, Defaults.FIELD_TYPE, null, null, null, null, null, null, indexSettings);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -25,10 +25,18 @@ import org.apache.lucene.document.FieldType;
|
|||
import org.elasticsearch.common.Strings;
|
||||
import org.elasticsearch.common.geo.GeoPoint;
|
||||
import org.elasticsearch.common.geo.builders.ShapeBuilder;
|
||||
import org.elasticsearch.common.settings.ImmutableSettings;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||
import org.elasticsearch.index.fielddata.FieldDataType;
|
||||
import org.elasticsearch.index.mapper.*;
|
||||
import org.elasticsearch.index.mapper.ContentPath;
|
||||
import org.elasticsearch.index.mapper.FieldMapper;
|
||||
import org.elasticsearch.index.mapper.FieldMapperListener;
|
||||
import org.elasticsearch.index.mapper.Mapper;
|
||||
import org.elasticsearch.index.mapper.MapperParsingException;
|
||||
import org.elasticsearch.index.mapper.MergeContext;
|
||||
import org.elasticsearch.index.mapper.MergeMappingException;
|
||||
import org.elasticsearch.index.mapper.ObjectMapperListener;
|
||||
import org.elasticsearch.index.mapper.ParseContext;
|
||||
import org.elasticsearch.index.mapper.core.AbstractFieldMapper;
|
||||
import org.elasticsearch.index.mapper.core.BinaryFieldMapper;
|
||||
import org.elasticsearch.index.mapper.core.BooleanFieldMapper;
|
||||
|
@ -109,7 +117,7 @@ public class ExternalMapper extends AbstractFieldMapper<Object> {
|
|||
context.path().pathType(origPathType);
|
||||
|
||||
return new ExternalMapper(buildNames(context), generatedValue, mapperName, binMapper, boolMapper, pointMapper, shapeMapper, stringMapper,
|
||||
multiFieldsBuilder.build(this, context), copyTo);
|
||||
context.indexSettings(), multiFieldsBuilder.build(this, context), copyTo);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -154,8 +162,8 @@ public class ExternalMapper extends AbstractFieldMapper<Object> {
|
|||
public ExternalMapper(FieldMapper.Names names,
|
||||
String generatedValue, String mapperName,
|
||||
BinaryFieldMapper binMapper, BooleanFieldMapper boolMapper, GeoPointFieldMapper pointMapper,
|
||||
GeoShapeFieldMapper shapeMapper, Mapper stringMapper, MultiFields multiFields, CopyTo copyTo) {
|
||||
super(names, 1.0f, Defaults.FIELD_TYPE, false, null, null, null, null, null, ImmutableSettings.EMPTY,
|
||||
GeoShapeFieldMapper shapeMapper, Mapper stringMapper, Settings indexSettings, MultiFields multiFields, CopyTo copyTo) {
|
||||
super(names, 1.0f, Defaults.FIELD_TYPE, false, null, null, null, null, null, indexSettings,
|
||||
multiFields, copyTo);
|
||||
this.generatedValue = generatedValue;
|
||||
this.mapperName = mapperName;
|
||||
|
|
|
@ -49,7 +49,11 @@ import org.apache.lucene.store.RAMDirectory;
|
|||
import org.apache.lucene.util.Bits;
|
||||
import org.apache.lucene.util.BytesRef;
|
||||
import org.apache.lucene.util.LineFileDocs;
|
||||
import org.elasticsearch.Version;
|
||||
import org.elasticsearch.cluster.metadata.IndexMetaData;
|
||||
import org.elasticsearch.common.lucene.Lucene;
|
||||
import org.elasticsearch.common.settings.ImmutableSettings;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.index.analysis.NamedAnalyzer;
|
||||
import org.elasticsearch.index.codec.postingsformat.Elasticsearch090PostingsFormat;
|
||||
import org.elasticsearch.index.mapper.FieldMapper.Names;
|
||||
|
@ -73,6 +77,8 @@ import static org.hamcrest.Matchers.equalTo;
|
|||
import static org.hamcrest.Matchers.is;
|
||||
|
||||
public class CompletionPostingsFormatTest extends ElasticsearchTestCase {
|
||||
|
||||
Settings indexSettings = ImmutableSettings.builder().put(IndexMetaData.SETTING_VERSION_CREATED, Version.CURRENT.id).build();
|
||||
|
||||
@Test
|
||||
public void testCompletionPostingsFormat() throws IOException {
|
||||
|
@ -88,7 +94,7 @@ public class CompletionPostingsFormatTest extends ElasticsearchTestCase {
|
|||
LookupFactory load = currentProvider.load(input);
|
||||
PostingsFormat format = PostingsFormat.forName(Lucene.LATEST_POSTINGS_FORMAT);
|
||||
NamedAnalyzer analyzer = new NamedAnalyzer("foo", new StandardAnalyzer());
|
||||
Lookup lookup = load.getLookup(new CompletionFieldMapper(new Names("foo"), analyzer, analyzer, format, null, true, true, true, Integer.MAX_VALUE, AbstractFieldMapper.MultiFields.empty(), null, ContextMapping.EMPTY_MAPPING), new CompletionSuggestionContext(null));
|
||||
Lookup lookup = load.getLookup(new CompletionFieldMapper(new Names("foo"), analyzer, analyzer, format, null, true, true, true, Integer.MAX_VALUE, indexSettings, AbstractFieldMapper.MultiFields.empty(), null, ContextMapping.EMPTY_MAPPING), new CompletionSuggestionContext(null));
|
||||
List<LookupResult> result = lookup.lookup("ge", false, 10);
|
||||
assertThat(result.get(0).key.toString(), equalTo("Generator - Foo Fighters"));
|
||||
assertThat(result.get(0).payload.utf8ToString(), equalTo("id:10"));
|
||||
|
@ -107,7 +113,7 @@ public class CompletionPostingsFormatTest extends ElasticsearchTestCase {
|
|||
LookupFactory load = currentProvider.load(input);
|
||||
PostingsFormat format = new Elasticsearch090PostingsFormat();
|
||||
NamedAnalyzer analyzer = new NamedAnalyzer("foo", new StandardAnalyzer());
|
||||
AnalyzingCompletionLookupProvider.AnalyzingSuggestHolder analyzingSuggestHolder = load.getAnalyzingSuggestHolder(new CompletionFieldMapper(new Names("foo"), analyzer, analyzer, format, null, true, true, true, Integer.MAX_VALUE, AbstractFieldMapper.MultiFields.empty(), null, ContextMapping.EMPTY_MAPPING));
|
||||
AnalyzingCompletionLookupProvider.AnalyzingSuggestHolder analyzingSuggestHolder = load.getAnalyzingSuggestHolder(new CompletionFieldMapper(new Names("foo"), analyzer, analyzer, format, null, true, true, true, Integer.MAX_VALUE, indexSettings, AbstractFieldMapper.MultiFields.empty(), null, ContextMapping.EMPTY_MAPPING));
|
||||
assertThat(analyzingSuggestHolder.sepLabel, is(AnalyzingCompletionLookupProviderV1.SEP_LABEL));
|
||||
assertThat(analyzingSuggestHolder.payloadSep, is(AnalyzingCompletionLookupProviderV1.PAYLOAD_SEP));
|
||||
assertThat(analyzingSuggestHolder.endByte, is(AnalyzingCompletionLookupProviderV1.END_BYTE));
|
||||
|
@ -125,7 +131,7 @@ public class CompletionPostingsFormatTest extends ElasticsearchTestCase {
|
|||
LookupFactory load = currentProvider.load(input);
|
||||
PostingsFormat format = new Elasticsearch090PostingsFormat();
|
||||
NamedAnalyzer analyzer = new NamedAnalyzer("foo", new StandardAnalyzer());
|
||||
AnalyzingCompletionLookupProvider.AnalyzingSuggestHolder analyzingSuggestHolder = load.getAnalyzingSuggestHolder(new CompletionFieldMapper(new Names("foo"), analyzer, analyzer, format, null, true, true, true, Integer.MAX_VALUE, AbstractFieldMapper.MultiFields.empty(), null, ContextMapping.EMPTY_MAPPING));
|
||||
AnalyzingCompletionLookupProvider.AnalyzingSuggestHolder analyzingSuggestHolder = load.getAnalyzingSuggestHolder(new CompletionFieldMapper(new Names("foo"), analyzer, analyzer, format, null, true, true, true, Integer.MAX_VALUE, indexSettings, AbstractFieldMapper.MultiFields.empty(), null, ContextMapping.EMPTY_MAPPING));
|
||||
assertThat(analyzingSuggestHolder.sepLabel, is(XAnalyzingSuggester.SEP_LABEL));
|
||||
assertThat(analyzingSuggestHolder.payloadSep, is(XAnalyzingSuggester.PAYLOAD_SEP));
|
||||
assertThat(analyzingSuggestHolder.endByte, is(XAnalyzingSuggester.END_BYTE));
|
||||
|
@ -234,7 +240,7 @@ public class CompletionPostingsFormatTest extends ElasticsearchTestCase {
|
|||
|
||||
NamedAnalyzer namedAnalzyer = new NamedAnalyzer("foo", new StandardAnalyzer());
|
||||
final CompletionFieldMapper mapper = new CompletionFieldMapper(new Names("foo"), namedAnalzyer, namedAnalzyer, provider, null, usePayloads,
|
||||
preserveSeparators, preservePositionIncrements, Integer.MAX_VALUE, AbstractFieldMapper.MultiFields.empty(), null, ContextMapping.EMPTY_MAPPING);
|
||||
preserveSeparators, preservePositionIncrements, Integer.MAX_VALUE, indexSettings, AbstractFieldMapper.MultiFields.empty(), null, ContextMapping.EMPTY_MAPPING);
|
||||
Lookup buildAnalyzingLookup = buildAnalyzingLookup(mapper, titles, titles, weights);
|
||||
Field field = buildAnalyzingLookup.getClass().getDeclaredField("maxAnalyzedPathsForOneInput");
|
||||
field.setAccessible(true);
|
||||
|
@ -335,7 +341,7 @@ public class CompletionPostingsFormatTest extends ElasticsearchTestCase {
|
|||
LookupFactory load = provider.load(input);
|
||||
PostingsFormat format = new Elasticsearch090PostingsFormat();
|
||||
NamedAnalyzer analyzer = new NamedAnalyzer("foo", new StandardAnalyzer());
|
||||
assertNull(load.getLookup(new CompletionFieldMapper(new Names("foo"), analyzer, analyzer, format, null, true, true, true, Integer.MAX_VALUE, AbstractFieldMapper.MultiFields.empty(), null, ContextMapping.EMPTY_MAPPING), new CompletionSuggestionContext(null)));
|
||||
assertNull(load.getLookup(new CompletionFieldMapper(new Names("foo"), analyzer, analyzer, format, null, true, true, true, Integer.MAX_VALUE, indexSettings, AbstractFieldMapper.MultiFields.empty(), null, ContextMapping.EMPTY_MAPPING), new CompletionSuggestionContext(null)));
|
||||
dir.close();
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue