Small refactorings to analysis components (#40745)
This change adds the following internal refactorings: * wraps input analyzers into an unmodifiable map in IndexAnalyzers ctor * removes duplicated indexSetting in IndexAnalyzers * removes references to IndexAnalyzers from DocumentMapperParser and TypeParser.ParserContext. It can always be retrieve it from MapperService directly in those cases
This commit is contained in:
parent
324fef0548
commit
09ba3ec677
|
@ -63,8 +63,8 @@ public class Murmur3FieldMapperTests extends ESSingleNodeTestCase {
|
||||||
Supplier<QueryShardContext> queryShardContext = () -> {
|
Supplier<QueryShardContext> queryShardContext = () -> {
|
||||||
return indexService.newQueryShardContext(0, null, () -> { throw new UnsupportedOperationException(); }, null);
|
return indexService.newQueryShardContext(0, null, () -> { throw new UnsupportedOperationException(); }, null);
|
||||||
};
|
};
|
||||||
parser = new DocumentMapperParser(indexService.getIndexSettings(), indexService.mapperService(), indexService.getIndexAnalyzers(),
|
parser = new DocumentMapperParser(indexService.getIndexSettings(), indexService.mapperService(), indexService.xContentRegistry(),
|
||||||
indexService.xContentRegistry(), indexService.similarityService(), mapperRegistry, queryShardContext);
|
indexService.similarityService(), mapperRegistry, queryShardContext);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -469,8 +469,8 @@ public final class AnalysisRegistry implements Closeable {
|
||||||
throw new IllegalArgumentException("analyzer name must not start with '_'. got \"" + analyzer.getKey() + "\"");
|
throw new IllegalArgumentException("analyzer name must not start with '_'. got \"" + analyzer.getKey() + "\"");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return new IndexAnalyzers(indexSettings, defaultAnalyzer, defaultSearchAnalyzer, defaultSearchQuoteAnalyzer,
|
return new IndexAnalyzers(indexSettings, defaultAnalyzer, defaultSearchAnalyzer, defaultSearchQuoteAnalyzer, analyzers, normalizers,
|
||||||
unmodifiableMap(analyzers), unmodifiableMap(normalizers), unmodifiableMap(whitespaceNormalizers));
|
whitespaceNormalizers);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void processAnalyzerFactory(IndexSettings indexSettings,
|
private void processAnalyzerFactory(IndexSettings indexSettings,
|
||||||
|
|
|
@ -27,6 +27,8 @@ import java.io.IOException;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
|
import static java.util.Collections.unmodifiableMap;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* IndexAnalyzers contains a name to analyzer mapping for a specific index.
|
* IndexAnalyzers contains a name to analyzer mapping for a specific index.
|
||||||
* This class only holds analyzers that are explicitly configured for an index and doesn't allow
|
* This class only holds analyzers that are explicitly configured for an index and doesn't allow
|
||||||
|
@ -41,7 +43,6 @@ public final class IndexAnalyzers extends AbstractIndexComponent implements Clos
|
||||||
private final Map<String, NamedAnalyzer> analyzers;
|
private final Map<String, NamedAnalyzer> analyzers;
|
||||||
private final Map<String, NamedAnalyzer> normalizers;
|
private final Map<String, NamedAnalyzer> normalizers;
|
||||||
private final Map<String, NamedAnalyzer> whitespaceNormalizers;
|
private final Map<String, NamedAnalyzer> whitespaceNormalizers;
|
||||||
private final IndexSettings indexSettings;
|
|
||||||
|
|
||||||
public IndexAnalyzers(IndexSettings indexSettings, NamedAnalyzer defaultIndexAnalyzer, NamedAnalyzer defaultSearchAnalyzer,
|
public IndexAnalyzers(IndexSettings indexSettings, NamedAnalyzer defaultIndexAnalyzer, NamedAnalyzer defaultSearchAnalyzer,
|
||||||
NamedAnalyzer defaultSearchQuoteAnalyzer, Map<String, NamedAnalyzer> analyzers,
|
NamedAnalyzer defaultSearchQuoteAnalyzer, Map<String, NamedAnalyzer> analyzers,
|
||||||
|
@ -53,10 +54,9 @@ public final class IndexAnalyzers extends AbstractIndexComponent implements Clos
|
||||||
this.defaultIndexAnalyzer = defaultIndexAnalyzer;
|
this.defaultIndexAnalyzer = defaultIndexAnalyzer;
|
||||||
this.defaultSearchAnalyzer = defaultSearchAnalyzer;
|
this.defaultSearchAnalyzer = defaultSearchAnalyzer;
|
||||||
this.defaultSearchQuoteAnalyzer = defaultSearchQuoteAnalyzer;
|
this.defaultSearchQuoteAnalyzer = defaultSearchQuoteAnalyzer;
|
||||||
this.analyzers = analyzers;
|
this.analyzers = unmodifiableMap(analyzers);
|
||||||
this.normalizers = normalizers;
|
this.normalizers = unmodifiableMap(normalizers);
|
||||||
this.whitespaceNormalizers = whitespaceNormalizers;
|
this.whitespaceNormalizers = unmodifiableMap(whitespaceNormalizers);
|
||||||
this.indexSettings = indexSettings;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -107,12 +107,4 @@ public final class IndexAnalyzers extends AbstractIndexComponent implements Clos
|
||||||
.filter(a -> a.scope() == AnalyzerScope.INDEX)
|
.filter(a -> a.scope() == AnalyzerScope.INDEX)
|
||||||
.iterator());
|
.iterator());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the indices settings
|
|
||||||
*/
|
|
||||||
public IndexSettings getIndexSettings() {
|
|
||||||
return indexSettings;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,7 +29,6 @@ import org.elasticsearch.common.xcontent.XContentHelper;
|
||||||
import org.elasticsearch.common.xcontent.XContentParser;
|
import org.elasticsearch.common.xcontent.XContentParser;
|
||||||
import org.elasticsearch.common.xcontent.XContentType;
|
import org.elasticsearch.common.xcontent.XContentType;
|
||||||
import org.elasticsearch.index.IndexSettings;
|
import org.elasticsearch.index.IndexSettings;
|
||||||
import org.elasticsearch.index.analysis.IndexAnalyzers;
|
|
||||||
import org.elasticsearch.index.query.QueryShardContext;
|
import org.elasticsearch.index.query.QueryShardContext;
|
||||||
import org.elasticsearch.index.similarity.SimilarityService;
|
import org.elasticsearch.index.similarity.SimilarityService;
|
||||||
import org.elasticsearch.indices.mapper.MapperRegistry;
|
import org.elasticsearch.indices.mapper.MapperRegistry;
|
||||||
|
@ -44,7 +43,6 @@ import static java.util.Collections.unmodifiableMap;
|
||||||
public class DocumentMapperParser {
|
public class DocumentMapperParser {
|
||||||
|
|
||||||
final MapperService mapperService;
|
final MapperService mapperService;
|
||||||
final IndexAnalyzers indexAnalyzers;
|
|
||||||
private final NamedXContentRegistry xContentRegistry;
|
private final NamedXContentRegistry xContentRegistry;
|
||||||
private final SimilarityService similarityService;
|
private final SimilarityService similarityService;
|
||||||
private final Supplier<QueryShardContext> queryShardContextSupplier;
|
private final Supplier<QueryShardContext> queryShardContextSupplier;
|
||||||
|
@ -56,11 +54,9 @@ public class DocumentMapperParser {
|
||||||
private final Map<String, Mapper.TypeParser> typeParsers;
|
private final Map<String, Mapper.TypeParser> typeParsers;
|
||||||
private final Map<String, MetadataFieldMapper.TypeParser> rootTypeParsers;
|
private final Map<String, MetadataFieldMapper.TypeParser> rootTypeParsers;
|
||||||
|
|
||||||
public DocumentMapperParser(IndexSettings indexSettings, MapperService mapperService, IndexAnalyzers indexAnalyzers,
|
public DocumentMapperParser(IndexSettings indexSettings, MapperService mapperService, NamedXContentRegistry xContentRegistry,
|
||||||
NamedXContentRegistry xContentRegistry, SimilarityService similarityService, MapperRegistry mapperRegistry,
|
SimilarityService similarityService, MapperRegistry mapperRegistry, Supplier<QueryShardContext> queryShardContextSupplier) {
|
||||||
Supplier<QueryShardContext> queryShardContextSupplier) {
|
|
||||||
this.mapperService = mapperService;
|
this.mapperService = mapperService;
|
||||||
this.indexAnalyzers = indexAnalyzers;
|
|
||||||
this.xContentRegistry = xContentRegistry;
|
this.xContentRegistry = xContentRegistry;
|
||||||
this.similarityService = similarityService;
|
this.similarityService = similarityService;
|
||||||
this.queryShardContextSupplier = queryShardContextSupplier;
|
this.queryShardContextSupplier = queryShardContextSupplier;
|
||||||
|
@ -70,7 +66,7 @@ public class DocumentMapperParser {
|
||||||
}
|
}
|
||||||
|
|
||||||
public Mapper.TypeParser.ParserContext parserContext(String type) {
|
public Mapper.TypeParser.ParserContext parserContext(String type) {
|
||||||
return new Mapper.TypeParser.ParserContext(type, indexAnalyzers, similarityService::getSimilarity, mapperService,
|
return new Mapper.TypeParser.ParserContext(type, similarityService::getSimilarity, mapperService,
|
||||||
typeParsers::get, indexVersionCreated, queryShardContextSupplier);
|
typeParsers::get, indexVersionCreated, queryShardContextSupplier);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -80,8 +80,6 @@ public abstract class Mapper implements ToXContentFragment, Iterable<Mapper> {
|
||||||
|
|
||||||
private final String type;
|
private final String type;
|
||||||
|
|
||||||
private final IndexAnalyzers indexAnalyzers;
|
|
||||||
|
|
||||||
private final Function<String, SimilarityProvider> similarityLookupService;
|
private final Function<String, SimilarityProvider> similarityLookupService;
|
||||||
|
|
||||||
private final MapperService mapperService;
|
private final MapperService mapperService;
|
||||||
|
@ -92,11 +90,10 @@ public abstract class Mapper implements ToXContentFragment, Iterable<Mapper> {
|
||||||
|
|
||||||
private final Supplier<QueryShardContext> queryShardContextSupplier;
|
private final Supplier<QueryShardContext> queryShardContextSupplier;
|
||||||
|
|
||||||
public ParserContext(String type, IndexAnalyzers indexAnalyzers, Function<String, SimilarityProvider> similarityLookupService,
|
public ParserContext(String type, Function<String, SimilarityProvider> similarityLookupService,
|
||||||
MapperService mapperService, Function<String, TypeParser> typeParsers,
|
MapperService mapperService, Function<String, TypeParser> typeParsers,
|
||||||
Version indexVersionCreated, Supplier<QueryShardContext> queryShardContextSupplier) {
|
Version indexVersionCreated, Supplier<QueryShardContext> queryShardContextSupplier) {
|
||||||
this.type = type;
|
this.type = type;
|
||||||
this.indexAnalyzers = indexAnalyzers;
|
|
||||||
this.similarityLookupService = similarityLookupService;
|
this.similarityLookupService = similarityLookupService;
|
||||||
this.mapperService = mapperService;
|
this.mapperService = mapperService;
|
||||||
this.typeParsers = typeParsers;
|
this.typeParsers = typeParsers;
|
||||||
|
@ -109,7 +106,7 @@ public abstract class Mapper implements ToXContentFragment, Iterable<Mapper> {
|
||||||
}
|
}
|
||||||
|
|
||||||
public IndexAnalyzers getIndexAnalyzers() {
|
public IndexAnalyzers getIndexAnalyzers() {
|
||||||
return indexAnalyzers;
|
return mapperService.getIndexAnalyzers();
|
||||||
}
|
}
|
||||||
|
|
||||||
public SimilarityProvider getSimilarity(String name) {
|
public SimilarityProvider getSimilarity(String name) {
|
||||||
|
@ -147,7 +144,7 @@ public abstract class Mapper implements ToXContentFragment, Iterable<Mapper> {
|
||||||
|
|
||||||
static class MultiFieldParserContext extends ParserContext {
|
static class MultiFieldParserContext extends ParserContext {
|
||||||
MultiFieldParserContext(ParserContext in) {
|
MultiFieldParserContext(ParserContext in) {
|
||||||
super(in.type(), in.indexAnalyzers, in.similarityLookupService(), in.mapperService(), in.typeParsers(),
|
super(in.type(), in.similarityLookupService(), in.mapperService(), in.typeParsers(),
|
||||||
in.indexVersionCreated(), in.queryShardContextSupplier());
|
in.indexVersionCreated(), in.queryShardContextSupplier());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,6 +21,7 @@ package org.elasticsearch.index.mapper;
|
||||||
|
|
||||||
import com.carrotsearch.hppc.ObjectHashSet;
|
import com.carrotsearch.hppc.ObjectHashSet;
|
||||||
import com.carrotsearch.hppc.cursors.ObjectCursor;
|
import com.carrotsearch.hppc.cursors.ObjectCursor;
|
||||||
|
|
||||||
import org.apache.logging.log4j.LogManager;
|
import org.apache.logging.log4j.LogManager;
|
||||||
import org.apache.logging.log4j.message.ParameterizedMessage;
|
import org.apache.logging.log4j.message.ParameterizedMessage;
|
||||||
import org.apache.lucene.analysis.Analyzer;
|
import org.apache.lucene.analysis.Analyzer;
|
||||||
|
@ -148,8 +149,8 @@ public class MapperService extends AbstractIndexComponent implements Closeable {
|
||||||
super(indexSettings);
|
super(indexSettings);
|
||||||
this.indexAnalyzers = indexAnalyzers;
|
this.indexAnalyzers = indexAnalyzers;
|
||||||
this.fieldTypes = new FieldTypeLookup();
|
this.fieldTypes = new FieldTypeLookup();
|
||||||
this.documentParser = new DocumentMapperParser(indexSettings, this, indexAnalyzers, xContentRegistry, similarityService,
|
this.documentParser = new DocumentMapperParser(indexSettings, this, xContentRegistry, similarityService, mapperRegistry,
|
||||||
mapperRegistry, queryShardContextSupplier);
|
queryShardContextSupplier);
|
||||||
this.indexAnalyzer = new MapperAnalyzerWrapper(indexAnalyzers.getDefaultIndexAnalyzer(), p -> p.indexAnalyzer());
|
this.indexAnalyzer = new MapperAnalyzerWrapper(indexAnalyzers.getDefaultIndexAnalyzer(), p -> p.indexAnalyzer());
|
||||||
this.searchAnalyzer = new MapperAnalyzerWrapper(indexAnalyzers.getDefaultSearchAnalyzer(), p -> p.searchAnalyzer());
|
this.searchAnalyzer = new MapperAnalyzerWrapper(indexAnalyzers.getDefaultSearchAnalyzer(), p -> p.searchAnalyzer());
|
||||||
this.searchQuoteAnalyzer = new MapperAnalyzerWrapper(indexAnalyzers.getDefaultSearchQuoteAnalyzer(), p -> p.searchQuoteAnalyzer());
|
this.searchQuoteAnalyzer = new MapperAnalyzerWrapper(indexAnalyzers.getDefaultSearchQuoteAnalyzer(), p -> p.searchQuoteAnalyzer());
|
||||||
|
|
|
@ -75,8 +75,7 @@ public class ExternalFieldMapperTests extends ESSingleNodeTestCase {
|
||||||
return indexService.newQueryShardContext(0, null, () -> { throw new UnsupportedOperationException(); }, null);
|
return indexService.newQueryShardContext(0, null, () -> { throw new UnsupportedOperationException(); }, null);
|
||||||
};
|
};
|
||||||
DocumentMapperParser parser = new DocumentMapperParser(indexService.getIndexSettings(), indexService.mapperService(),
|
DocumentMapperParser parser = new DocumentMapperParser(indexService.getIndexSettings(), indexService.mapperService(),
|
||||||
indexService.getIndexAnalyzers(), indexService.xContentRegistry(), indexService.similarityService(), mapperRegistry,
|
indexService.xContentRegistry(), indexService.similarityService(), mapperRegistry, queryShardContext);
|
||||||
queryShardContext);
|
|
||||||
DocumentMapper documentMapper = parser.parse("type", new CompressedXContent(
|
DocumentMapper documentMapper = parser.parse("type", new CompressedXContent(
|
||||||
Strings.toString(XContentFactory.jsonBuilder().startObject().startObject("type")
|
Strings.toString(XContentFactory.jsonBuilder().startObject().startObject("type")
|
||||||
.startObject(ExternalMetadataMapper.CONTENT_TYPE)
|
.startObject(ExternalMetadataMapper.CONTENT_TYPE)
|
||||||
|
@ -123,8 +122,7 @@ public class ExternalFieldMapperTests extends ESSingleNodeTestCase {
|
||||||
return indexService.newQueryShardContext(0, null, () -> { throw new UnsupportedOperationException(); }, null);
|
return indexService.newQueryShardContext(0, null, () -> { throw new UnsupportedOperationException(); }, null);
|
||||||
};
|
};
|
||||||
DocumentMapperParser parser = new DocumentMapperParser(indexService.getIndexSettings(), indexService.mapperService(),
|
DocumentMapperParser parser = new DocumentMapperParser(indexService.getIndexSettings(), indexService.mapperService(),
|
||||||
indexService.getIndexAnalyzers(), indexService.xContentRegistry(), indexService.similarityService(), mapperRegistry,
|
indexService.xContentRegistry(), indexService.similarityService(), mapperRegistry, queryShardContext);
|
||||||
queryShardContext);
|
|
||||||
|
|
||||||
DocumentMapper documentMapper = parser.parse("type", new CompressedXContent(
|
DocumentMapper documentMapper = parser.parse("type", new CompressedXContent(
|
||||||
Strings
|
Strings
|
||||||
|
@ -186,8 +184,7 @@ public class ExternalFieldMapperTests extends ESSingleNodeTestCase {
|
||||||
return indexService.newQueryShardContext(0, null, () -> { throw new UnsupportedOperationException(); }, null);
|
return indexService.newQueryShardContext(0, null, () -> { throw new UnsupportedOperationException(); }, null);
|
||||||
};
|
};
|
||||||
DocumentMapperParser parser = new DocumentMapperParser(indexService.getIndexSettings(), indexService.mapperService(),
|
DocumentMapperParser parser = new DocumentMapperParser(indexService.getIndexSettings(), indexService.mapperService(),
|
||||||
indexService.getIndexAnalyzers(), indexService.xContentRegistry(), indexService.similarityService(), mapperRegistry,
|
indexService.xContentRegistry(), indexService.similarityService(), mapperRegistry, queryShardContext);
|
||||||
queryShardContext);
|
|
||||||
|
|
||||||
DocumentMapper documentMapper = parser.parse("type", new CompressedXContent(
|
DocumentMapper documentMapper = parser.parse("type", new CompressedXContent(
|
||||||
Strings
|
Strings
|
||||||
|
|
|
@ -36,6 +36,7 @@ import org.elasticsearch.index.analysis.NamedAnalyzer;
|
||||||
import org.elasticsearch.index.analysis.TokenFilterFactory;
|
import org.elasticsearch.index.analysis.TokenFilterFactory;
|
||||||
import org.elasticsearch.test.ESTestCase;
|
import org.elasticsearch.test.ESTestCase;
|
||||||
|
|
||||||
|
import java.util.Collections;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
@ -60,8 +61,8 @@ public class TypeParsersTests extends ESTestCase {
|
||||||
analyzers.put("my_analyzer",
|
analyzers.put("my_analyzer",
|
||||||
new NamedAnalyzer("my_named_analyzer", AnalyzerScope.INDEX, createAnalyzerWithMode("my_analyzer", AnalysisMode.ALL)));
|
new NamedAnalyzer("my_named_analyzer", AnalyzerScope.INDEX, createAnalyzerWithMode("my_analyzer", AnalysisMode.ALL)));
|
||||||
|
|
||||||
IndexAnalyzers indexAnalyzers = new IndexAnalyzers(indexSettings,
|
IndexAnalyzers indexAnalyzers = new IndexAnalyzers(indexSettings, new NamedAnalyzer("default", AnalyzerScope.INDEX, null), null,
|
||||||
new NamedAnalyzer("default", AnalyzerScope.INDEX, null), null, null, analyzers, null, null);
|
null, analyzers, Collections.emptyMap(), Collections.emptyMap());
|
||||||
when(parserContext.getIndexAnalyzers()).thenReturn(indexAnalyzers);
|
when(parserContext.getIndexAnalyzers()).thenReturn(indexAnalyzers);
|
||||||
TypeParsers.parseTextField(builder, "name", new HashMap<>(fieldNode), parserContext);
|
TypeParsers.parseTextField(builder, "name", new HashMap<>(fieldNode), parserContext);
|
||||||
|
|
||||||
|
@ -71,7 +72,7 @@ public class TypeParsersTests extends ESTestCase {
|
||||||
analyzers.put("my_analyzer", new NamedAnalyzer("my_named_analyzer", AnalyzerScope.INDEX,
|
analyzers.put("my_analyzer", new NamedAnalyzer("my_named_analyzer", AnalyzerScope.INDEX,
|
||||||
createAnalyzerWithMode("my_analyzer", mode)));
|
createAnalyzerWithMode("my_analyzer", mode)));
|
||||||
indexAnalyzers = new IndexAnalyzers(indexSettings, new NamedAnalyzer("default", AnalyzerScope.INDEX, null), null, null, analyzers,
|
indexAnalyzers = new IndexAnalyzers(indexSettings, new NamedAnalyzer("default", AnalyzerScope.INDEX, null), null, null, analyzers,
|
||||||
null, null);
|
Collections.emptyMap(), Collections.emptyMap());
|
||||||
when(parserContext.getIndexAnalyzers()).thenReturn(indexAnalyzers);
|
when(parserContext.getIndexAnalyzers()).thenReturn(indexAnalyzers);
|
||||||
MapperException ex = expectThrows(MapperException.class,
|
MapperException ex = expectThrows(MapperException.class,
|
||||||
() -> TypeParsers.parseTextField(builder, "name", new HashMap<>(fieldNode), parserContext));
|
() -> TypeParsers.parseTextField(builder, "name", new HashMap<>(fieldNode), parserContext));
|
||||||
|
@ -98,7 +99,7 @@ public class TypeParsersTests extends ESTestCase {
|
||||||
analyzers.put("standard", new NamedAnalyzer("standard", AnalyzerScope.INDEX, new StandardAnalyzer()));
|
analyzers.put("standard", new NamedAnalyzer("standard", AnalyzerScope.INDEX, new StandardAnalyzer()));
|
||||||
|
|
||||||
IndexAnalyzers indexAnalyzers = new IndexAnalyzers(indexSettings, new NamedAnalyzer("default", AnalyzerScope.INDEX, null), null,
|
IndexAnalyzers indexAnalyzers = new IndexAnalyzers(indexSettings, new NamedAnalyzer("default", AnalyzerScope.INDEX, null), null,
|
||||||
null, analyzers, null, null);
|
null, analyzers, Collections.emptyMap(), Collections.emptyMap());
|
||||||
when(parserContext.getIndexAnalyzers()).thenReturn(indexAnalyzers);
|
when(parserContext.getIndexAnalyzers()).thenReturn(indexAnalyzers);
|
||||||
TypeParsers.parseTextField(builder, "name", new HashMap<>(fieldNode), parserContext);
|
TypeParsers.parseTextField(builder, "name", new HashMap<>(fieldNode), parserContext);
|
||||||
|
|
||||||
|
@ -109,7 +110,7 @@ public class TypeParsersTests extends ESTestCase {
|
||||||
new NamedAnalyzer("my_named_analyzer", AnalyzerScope.INDEX, createAnalyzerWithMode("my_analyzer", mode)));
|
new NamedAnalyzer("my_named_analyzer", AnalyzerScope.INDEX, createAnalyzerWithMode("my_analyzer", mode)));
|
||||||
analyzers.put("standard", new NamedAnalyzer("standard", AnalyzerScope.INDEX, new StandardAnalyzer()));
|
analyzers.put("standard", new NamedAnalyzer("standard", AnalyzerScope.INDEX, new StandardAnalyzer()));
|
||||||
indexAnalyzers = new IndexAnalyzers(indexSettings, new NamedAnalyzer("default", AnalyzerScope.INDEX, null), null, null,
|
indexAnalyzers = new IndexAnalyzers(indexSettings, new NamedAnalyzer("default", AnalyzerScope.INDEX, null), null, null,
|
||||||
analyzers, null, null);
|
analyzers, Collections.emptyMap(), Collections.emptyMap());
|
||||||
when(parserContext.getIndexAnalyzers()).thenReturn(indexAnalyzers);
|
when(parserContext.getIndexAnalyzers()).thenReturn(indexAnalyzers);
|
||||||
MapperException ex = expectThrows(MapperException.class,
|
MapperException ex = expectThrows(MapperException.class,
|
||||||
() -> TypeParsers.parseTextField(builder, "name", new HashMap<>(fieldNode), parserContext));
|
() -> TypeParsers.parseTextField(builder, "name", new HashMap<>(fieldNode), parserContext));
|
||||||
|
@ -130,7 +131,7 @@ public class TypeParsersTests extends ESTestCase {
|
||||||
analyzers.put("my_analyzer",
|
analyzers.put("my_analyzer",
|
||||||
new NamedAnalyzer("my_named_analyzer", AnalyzerScope.INDEX, createAnalyzerWithMode("my_analyzer", mode)));
|
new NamedAnalyzer("my_named_analyzer", AnalyzerScope.INDEX, createAnalyzerWithMode("my_analyzer", mode)));
|
||||||
IndexAnalyzers indexAnalyzers = new IndexAnalyzers(indexSettings, new NamedAnalyzer("default", AnalyzerScope.INDEX, null), null,
|
IndexAnalyzers indexAnalyzers = new IndexAnalyzers(indexSettings, new NamedAnalyzer("default", AnalyzerScope.INDEX, null), null,
|
||||||
null, analyzers, null, null);
|
null, analyzers, Collections.emptyMap(), Collections.emptyMap());
|
||||||
when(parserContext.getIndexAnalyzers()).thenReturn(indexAnalyzers);
|
when(parserContext.getIndexAnalyzers()).thenReturn(indexAnalyzers);
|
||||||
MapperException ex = expectThrows(MapperException.class,
|
MapperException ex = expectThrows(MapperException.class,
|
||||||
() -> TypeParsers.parseTextField(builder, "name", new HashMap<>(fieldNode), parserContext));
|
() -> TypeParsers.parseTextField(builder, "name", new HashMap<>(fieldNode), parserContext));
|
||||||
|
@ -146,7 +147,7 @@ public class TypeParsersTests extends ESTestCase {
|
||||||
analyzers.put("standard", new NamedAnalyzer("standard", AnalyzerScope.INDEX, new StandardAnalyzer()));
|
analyzers.put("standard", new NamedAnalyzer("standard", AnalyzerScope.INDEX, new StandardAnalyzer()));
|
||||||
|
|
||||||
indexAnalyzers = new IndexAnalyzers(indexSettings, new NamedAnalyzer("default", AnalyzerScope.INDEX, null), null, null, analyzers,
|
indexAnalyzers = new IndexAnalyzers(indexSettings, new NamedAnalyzer("default", AnalyzerScope.INDEX, null), null, null, analyzers,
|
||||||
null, null);
|
Collections.emptyMap(), Collections.emptyMap());
|
||||||
when(parserContext.getIndexAnalyzers()).thenReturn(indexAnalyzers);
|
when(parserContext.getIndexAnalyzers()).thenReturn(indexAnalyzers);
|
||||||
TypeParsers.parseTextField(builder, "name", new HashMap<>(fieldNode), parserContext);
|
TypeParsers.parseTextField(builder, "name", new HashMap<>(fieldNode), parserContext);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue