org.elasticsearch.indices.mapper.MapperRegistry Java Examples
The following examples show how to use
org.elasticsearch.indices.mapper.MapperRegistry.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: MapperTestUtils.java From crate with Apache License 2.0 | 6 votes |
public static MapperService newMapperService(NamedXContentRegistry xContentRegistry, Path tempDir, Settings settings, IndicesModule indicesModule, String indexName) throws IOException { Settings.Builder settingsBuilder = Settings.builder() .put(Environment.PATH_HOME_SETTING.getKey(), tempDir) .put(settings); if (settings.get(IndexMetaData.SETTING_VERSION_CREATED) == null) { settingsBuilder.put(IndexMetaData.SETTING_VERSION_CREATED, Version.CURRENT); } Settings finalSettings = settingsBuilder.build(); MapperRegistry mapperRegistry = indicesModule.getMapperRegistry(); IndexSettings indexSettings = IndexSettingsModule.newIndexSettings(indexName, finalSettings); IndexAnalyzers indexAnalyzers = createTestAnalysis(indexSettings, finalSettings).indexAnalyzers; return new MapperService(indexSettings, indexAnalyzers, xContentRegistry, mapperRegistry, () -> null); }
Example #2
Source File: MetaDataIndexUpgradeService.java From crate with Apache License 2.0 | 6 votes |
public MetaDataIndexUpgradeService(Settings settings, NamedXContentRegistry xContentRegistry, MapperRegistry mapperRegistry, IndexScopedSettings indexScopedSettings, Collection<UnaryOperator<IndexMetaData>> indexMetaDataUpgraders) { this.settings = settings; this.xContentRegistry = xContentRegistry; this.mapperRegistry = mapperRegistry; this.indexScopedSettings = indexScopedSettings; this.upgraders = indexMetaData -> { IndexMetaData newIndexMetaData = indexMetaData; for (UnaryOperator<IndexMetaData> upgrader : indexMetaDataUpgraders) { newIndexMetaData = upgrader.apply(newIndexMetaData); } return newIndexMetaData; }; }
Example #3
Source File: MapperTestUtils.java From Elasticsearch with Apache License 2.0 | 6 votes |
public static MapperService newMapperService(Path tempDir, Settings indexSettings, IndicesModule indicesModule) { Settings.Builder settingsBuilder = Settings.builder() .put("path.home", tempDir) .put(indexSettings); if (indexSettings.get(IndexMetaData.SETTING_VERSION_CREATED) == null) { settingsBuilder.put(IndexMetaData.SETTING_VERSION_CREATED, Version.CURRENT); } Settings settings = settingsBuilder.build(); MapperRegistry mapperRegistry = indicesModule.getMapperRegistry(); return new MapperService(new Index("test"), settings, newAnalysisService(settings), newSimilarityLookupService(settings), null, mapperRegistry, new DynamicArrayFieldMapperBuilderFactoryProvider()); }
Example #4
Source File: MapperTestUtils.java From elasticsearch-analysis-baseform with Apache License 2.0 | 6 votes |
public static DocumentMapperParser newDocumentMapperParser(Settings settings) { Settings forcedSettings = Settings.builder() .put(IndexMetaData.SETTING_VERSION_CREATED, Version.CURRENT) .put(settings) .build(); SimilarityLookupService similarityLookupService = newSimilarityLookupService(forcedSettings); Map<String, Mapper.TypeParser> mappers = registerBuiltInMappers(); Map<String, MetadataFieldMapper.TypeParser> metadataMappers = registerBuiltInMetadataMappers(); MapperRegistry mapperRegistry = new MapperRegistry(mappers, metadataMappers); MapperService mapperService = new MapperService(new Index("test"), forcedSettings, newAnalysisService(forcedSettings), similarityLookupService, null, mapperRegistry); return new DocumentMapperParser( forcedSettings, mapperService, newAnalysisService(forcedSettings), similarityLookupService, null, mapperRegistry); }
Example #5
Source File: DocumentMapperParser.java From Elasticsearch with Apache License 2.0 | 5 votes |
public DocumentMapperParser(Settings indexSettings, MapperService mapperService, AnalysisService analysisService, SimilarityLookupService similarityLookupService, ScriptService scriptService, MapperRegistry mapperRegistry, @Nullable DynamicArrayFieldMapperBuilderFactory dynamicArrayFieldMapperBuilderFactory) { this.dynamicArrayFieldMapperBuilderFactory = dynamicArrayFieldMapperBuilderFactory; this.parseFieldMatcher = new ParseFieldMatcher(indexSettings); this.scriptService = scriptService; this.mapperService = mapperService; this.analysisService = analysisService; this.similarityLookupService = similarityLookupService; this.typeParsers = mapperRegistry.getMapperParsers(); this.rootTypeParsers = mapperRegistry.getMetadataMapperParsers(); indexVersionCreated = Version.indexCreated(indexSettings); }
Example #6
Source File: TranslogHandler.java From crate with Apache License 2.0 | 5 votes |
public TranslogHandler(NamedXContentRegistry xContentRegistry, IndexSettings indexSettings) { NamedAnalyzer defaultAnalyzer = new NamedAnalyzer("default", AnalyzerScope.INDEX, new StandardAnalyzer()); IndexAnalyzers indexAnalyzers = new IndexAnalyzers(indexSettings, defaultAnalyzer, defaultAnalyzer, defaultAnalyzer, emptyMap(), emptyMap(), emptyMap()); MapperRegistry mapperRegistry = new IndicesModule(emptyList()).getMapperRegistry(); mapperService = new MapperService(indexSettings, indexAnalyzers, xContentRegistry, mapperRegistry, () -> null); }
Example #7
Source File: MapperService.java From crate with Apache License 2.0 | 5 votes |
public MapperService(IndexSettings indexSettings, IndexAnalyzers indexAnalyzers, NamedXContentRegistry xContentRegistry, MapperRegistry mapperRegistry, Supplier<QueryShardContext> queryShardContextSupplier) { super(indexSettings); this.indexAnalyzers = indexAnalyzers; this.fieldTypes = new FieldTypeLookup(); this.documentParser = new DocumentMapperParser(indexSettings, this, indexAnalyzers, xContentRegistry, mapperRegistry, queryShardContextSupplier); this.indexAnalyzer = new MapperAnalyzerWrapper(indexAnalyzers.getDefaultIndexAnalyzer(), MappedFieldType::indexAnalyzer); this.searchAnalyzer = new MapperAnalyzerWrapper(indexAnalyzers.getDefaultSearchAnalyzer(), MappedFieldType::searchAnalyzer); this.searchQuoteAnalyzer = new MapperAnalyzerWrapper(indexAnalyzers.getDefaultSearchQuoteAnalyzer(), MappedFieldType::searchQuoteAnalyzer); this.mapperRegistry = mapperRegistry; }
Example #8
Source File: DocumentMapperParser.java From crate with Apache License 2.0 | 5 votes |
public DocumentMapperParser(IndexSettings indexSettings, MapperService mapperService, IndexAnalyzers indexAnalyzers, NamedXContentRegistry xContentRegistry, MapperRegistry mapperRegistry, Supplier<QueryShardContext> queryShardContextSupplier) { this.mapperService = mapperService; this.indexAnalyzers = indexAnalyzers; this.xContentRegistry = xContentRegistry; this.queryShardContextSupplier = queryShardContextSupplier; this.typeParsers = mapperRegistry.getMapperParsers(); this.rootTypeParsers = mapperRegistry.getMetadataMapperParsers(); indexVersionCreated = indexSettings.getIndexVersionCreated(); }
Example #9
Source File: IndexModule.java From crate with Apache License 2.0 | 5 votes |
/** * creates a new mapper service to do administrative work like mapping updates. This *should not* be used for document parsing. * doing so will result in an exception. */ public MapperService newIndexMapperService(NamedXContentRegistry xContentRegistry, MapperRegistry mapperRegistry) throws IOException { return new MapperService( indexSettings, analysisRegistry.build(indexSettings), xContentRegistry, mapperRegistry, () -> { throw new UnsupportedOperationException("no index query shard context available"); } ); }
Example #10
Source File: MapperTestUtils.java From elasticsearch-analysis-baseform with Apache License 2.0 | 5 votes |
public static MapperService newMapperService(Settings settings, Client client) { Settings indexSettings = Settings.builder() .put(IndexMetaData.SETTING_VERSION_CREATED, Version.CURRENT) .put("path.home", System.getProperty("path.home")) .put("client.type", "node") .put(settings) .build(); Index index = new Index("test"); Injector parentInjector = new ModulesBuilder() .add(new SettingsModule(indexSettings), new EnvironmentModule(new Environment(indexSettings))) .createInjector(); AnalysisModule analysisModule = new AnalysisModule(indexSettings, parentInjector.getInstance(IndicesAnalysisService.class)); new AnalysisBaseformPlugin(settings).onModule(analysisModule); Injector injector = new ModulesBuilder().add(new IndexSettingsModule(index, indexSettings), new IndexNameModule(index), analysisModule) .createChildInjector(parentInjector); AnalysisService analysisService = injector.getInstance(AnalysisService.class); SimilarityLookupService similarityLookupService = new SimilarityLookupService(index, indexSettings); Map<String, Mapper.TypeParser> mappers = registerBuiltInMappers(); Map<String, MetadataFieldMapper.TypeParser> metadataMappers = registerBuiltInMetadataMappers(); MapperRegistry mapperRegistry = new MapperRegistry(mappers, metadataMappers); return new MapperService(new Index("test"), indexSettings, analysisService, similarityLookupService, null, mapperRegistry); }
Example #11
Source File: MetaDataIndexUpgradeService.java From Elasticsearch with Apache License 2.0 | 5 votes |
@Inject public MetaDataIndexUpgradeService(Settings settings, ScriptService scriptService, MapperRegistry mapperRegistry, DynamicArrayFieldMapperBuilderFactoryProvider dynamicArrayFieldMapperBuilderFactoryProvider) { super(settings); this.scriptService = scriptService; this.mapperRegistry = mapperRegistry; this.dynamicArrayFieldMapperBuilderFactoryProvider = dynamicArrayFieldMapperBuilderFactoryProvider; final String pre20HashFunctionName = settings.get(DEPRECATED_SETTING_ROUTING_HASH_FUNCTION, null); final boolean hasCustomPre20HashFunction = pre20HashFunctionName != null; // the hash function package has changed we replace the two hash functions if their fully qualified name is used. if (hasCustomPre20HashFunction) { switch (pre20HashFunctionName) { case "Simple": case "simple": case "org.elasticsearch.cluster.routing.operation.hash.simple.SimpleHashFunction": pre20HashFunction = SimpleHashFunction.class; break; case "Djb": case "djb": case "org.elasticsearch.cluster.routing.operation.hash.djb.DjbHashFunction": pre20HashFunction = DjbHashFunction.class; break; default: try { pre20HashFunction = Class.forName(pre20HashFunctionName).asSubclass(HashFunction.class); } catch (ClassNotFoundException|NoClassDefFoundError e) { throw new ElasticsearchException("failed to load custom hash function [" + pre20HashFunctionName + "]", e); } } } else { pre20HashFunction = DjbHashFunction.class; } pre20UseType = settings.getAsBoolean(DEPRECATED_SETTING_ROUTING_USE_TYPE, null); if (hasCustomPre20HashFunction || pre20UseType != null) { logger.warn("Settings [{}] and [{}] are deprecated. Index settings from your old indices have been updated to record the fact that they " + "used some custom routing logic, you can now remove these settings from your `elasticsearch.yml` file", DEPRECATED_SETTING_ROUTING_HASH_FUNCTION, DEPRECATED_SETTING_ROUTING_USE_TYPE); } }
Example #12
Source File: MapperService.java From Elasticsearch with Apache License 2.0 | 5 votes |
public MapperService(Index index, Settings indexSettings, AnalysisService analysisService, SimilarityLookupService similarityLookupService, ScriptService scriptService, MapperRegistry mapperRegistry, DynamicArrayFieldMapperBuilderFactoryProvider dynamicArrayFieldMapperBuilderFactoryProvider) { this(index, new IndexSettingsService(index, indexSettings), analysisService, similarityLookupService, scriptService, mapperRegistry, dynamicArrayFieldMapperBuilderFactoryProvider); }
Example #13
Source File: IndicesModule.java From crate with Apache License 2.0 | 4 votes |
/** * A registry for all field mappers. */ public MapperRegistry getMapperRegistry() { return mapperRegistry; }
Example #14
Source File: IndicesService.java From crate with Apache License 2.0 | 4 votes |
public IndicesService(Settings settings, PluginsService pluginsService, NodeEnvironment nodeEnv, NamedXContentRegistry xContentRegistry, AnalysisRegistry analysisRegistry, MapperRegistry mapperRegistry, NamedWriteableRegistry namedWriteableRegistry, ThreadPool threadPool, IndexScopedSettings indexScopedSettings, CircuitBreakerService circuitBreakerService, BigArrays bigArrays, Client client, MetaStateService metaStateService, Collection<Function<IndexSettings, Optional<EngineFactory>>> engineFactoryProviders, Map<String, Function<IndexSettings, IndexStore>> indexStoreFactories) { this.settings = settings; this.threadPool = threadPool; this.pluginsService = pluginsService; this.nodeEnv = nodeEnv; this.xContentRegistry = xContentRegistry; this.shardsClosedTimeout = settings.getAsTime(INDICES_SHARDS_CLOSED_TIMEOUT, new TimeValue(1, TimeUnit.DAYS)); this.analysisRegistry = analysisRegistry; this.indicesQueryCache = new IndicesQueryCache(settings); this.mapperRegistry = mapperRegistry; this.namedWriteableRegistry = namedWriteableRegistry; indexingMemoryController = new IndexingMemoryController( settings, threadPool, // ensure we pull an iter with new shards - flatten makes a copy () -> Iterables.flatten(this).iterator() ); this.indexScopedSettings = indexScopedSettings; this.circuitBreakerService = circuitBreakerService; this.bigArrays = bigArrays; this.client = client; this.metaStateService = metaStateService; this.engineFactoryProviders = engineFactoryProviders; // do not allow any plugin-provided index store type to conflict with a built-in type for (final String indexStoreType : indexStoreFactories.keySet()) { if (IndexModule.isBuiltinType(indexStoreType)) { throw new IllegalStateException("registered index store type [" + indexStoreType + "] conflicts with a built-in type"); } } this.indexStoreFactories = indexStoreFactories; }
Example #15
Source File: IndicesService.java From crate with Apache License 2.0 | 4 votes |
public MapperRegistry getMapperRegistry() { return mapperRegistry; }
Example #16
Source File: IndexModule.java From crate with Apache License 2.0 | 4 votes |
public IndexService newIndexService( NodeEnvironment environment, NamedXContentRegistry xContentRegistry, IndexService.ShardStoreDeleter shardStoreDeleter, CircuitBreakerService circuitBreakerService, BigArrays bigArrays, ThreadPool threadPool, IndicesQueryCache indicesQueryCache, MapperRegistry mapperRegistry) throws IOException { final IndexEventListener eventListener = freeze(); IndexSearcherWrapperFactory searcherWrapperFactory = indexSearcherWrapper.get() == null ? (shard) -> null : indexSearcherWrapper.get(); eventListener.beforeIndexCreated(indexSettings.getIndex(), indexSettings.getSettings()); final IndexStore store = getIndexStore(indexSettings, indexStoreFactories); final QueryCache queryCache; if (indexSettings.getValue(INDEX_QUERY_CACHE_ENABLED_SETTING)) { BiFunction<IndexSettings, IndicesQueryCache, QueryCache> queryCacheProvider = forceQueryCacheProvider.get(); if (queryCacheProvider == null) { queryCache = new IndexQueryCache(indexSettings, indicesQueryCache); } else { queryCache = queryCacheProvider.apply(indexSettings, indicesQueryCache); } } else { queryCache = new DisabledQueryCache(indexSettings); } return new IndexService( indexSettings, environment, xContentRegistry, shardStoreDeleter, analysisRegistry, engineFactory, circuitBreakerService, bigArrays, threadPool, queryCache, store, eventListener, searcherWrapperFactory, mapperRegistry, indexOperationListeners ); }
Example #17
Source File: IndicesModule.java From crate with Apache License 2.0 | 4 votes |
public IndicesModule(List<MapperPlugin> mapperPlugins) { this.mapperRegistry = new MapperRegistry(getMappers(mapperPlugins), getMetadataMappers(mapperPlugins), getFieldFilter(mapperPlugins)); registerBuiltinWritables(); }
Example #18
Source File: IndexService.java From crate with Apache License 2.0 | 4 votes |
public IndexService( IndexSettings indexSettings, NodeEnvironment nodeEnv, NamedXContentRegistry xContentRegistry, ShardStoreDeleter shardStoreDeleter, AnalysisRegistry registry, EngineFactory engineFactory, CircuitBreakerService circuitBreakerService, BigArrays bigArrays, ThreadPool threadPool, QueryCache queryCache, IndexStore indexStore, IndexEventListener eventListener, IndexModule.IndexSearcherWrapperFactory wrapperFactory, MapperRegistry mapperRegistry, List<IndexingOperationListener> indexingOperationListeners) throws IOException { super(indexSettings); this.indexSettings = indexSettings; this.xContentRegistry = xContentRegistry; this.circuitBreakerService = circuitBreakerService; this.mapperService = new MapperService( indexSettings, registry.build(indexSettings), xContentRegistry, mapperRegistry, // we parse all percolator queries as they would be parsed on shard 0 this::newQueryShardContext ); this.shardStoreDeleter = shardStoreDeleter; this.bigArrays = bigArrays; this.threadPool = threadPool; this.eventListener = eventListener; this.nodeEnv = nodeEnv; this.indexStore = indexStore; this.indexCache = new IndexCache(indexSettings, queryCache); this.engineFactory = Objects.requireNonNull(engineFactory); // initialize this last -- otherwise if the wrapper requires any other member to be non-null we fail with an NPE this.searcherWrapper = wrapperFactory.newWrapper(this); this.indexingOperationListeners = Collections.unmodifiableList(indexingOperationListeners); // kick off async ops for the first shard in this index this.refreshTask = new AsyncRefreshTask(this); this.trimTranslogTask = new AsyncTrimTranslogTask(this); this.globalCheckpointTask = new AsyncGlobalCheckpointTask(this); rescheduleFsyncTask(indexSettings.getTranslogDurability()); }
Example #19
Source File: MapperService.java From Elasticsearch with Apache License 2.0 | 4 votes |
@Inject public MapperService(Index index, IndexSettingsService indexSettingsService, AnalysisService analysisService, SimilarityLookupService similarityLookupService, ScriptService scriptService, MapperRegistry mapperRegistry, DynamicArrayFieldMapperBuilderFactoryProvider dynamicArrayFieldMapperBuilderFactoryProvider) { super(index, indexSettingsService.getSettings()); this.indexSettings = indexSettingsService.getSettings(); this.indexSettingsService = indexSettingsService; this.analysisService = analysisService; this.mapperRegistry = mapperRegistry; this.fieldTypes = new FieldTypeLookup(); this.documentParser = new DocumentMapperParser(indexSettings, this, analysisService, similarityLookupService, scriptService, mapperRegistry, dynamicArrayFieldMapperBuilderFactoryProvider.get()); this.indexAnalyzer = new MapperAnalyzerWrapper(analysisService.defaultIndexAnalyzer(), INDEX_ANALYZER_EXTRACTOR); this.searchAnalyzer = new MapperAnalyzerWrapper(analysisService.defaultSearchAnalyzer(), SEARCH_ANALYZER_EXTRACTOR); this.searchQuoteAnalyzer = new MapperAnalyzerWrapper(analysisService.defaultSearchQuoteAnalyzer(), SEARCH_QUOTE_ANALYZER_EXTRACTOR); this.dynamic = this.indexSettings.getAsBoolean(INDEX_MAPPER_DYNAMIC_SETTING, INDEX_MAPPER_DYNAMIC_DEFAULT); defaultPercolatorMappingSource = "{\n" + "\"_default_\":{\n" + "\"properties\" : {\n" + "\"query\" : {\n" + "\"type\" : \"object\",\n" + "\"enabled\" : false\n" + "}\n" + "}\n" + "}\n" + "}"; if (index.getName().equals(ScriptService.SCRIPT_INDEX)){ defaultMappingSource = "{" + "\"_default_\": {" + "\"properties\": {" + "\"script\": { \"enabled\": false }," + "\"template\": { \"enabled\": false }" + "}" + "}" + "}"; } else { defaultMappingSource = "{\"_default_\":{}}"; } if (logger.isTraceEnabled()) { logger.trace("using dynamic[{}], default mapping source[{}], default percolator mapping source[{}]", dynamic, defaultMappingSource, defaultPercolatorMappingSource); } else if (logger.isDebugEnabled()) { logger.debug("using dynamic[{}]", dynamic); } }
Example #20
Source File: IndicesModule.java From Elasticsearch with Apache License 2.0 | 4 votes |
protected void bindMapperExtension() { bind(MapperRegistry.class).toInstance(getMapperRegistry()); }