Class IndexModule
- java.lang.Object
-
- org.elasticsearch.index.IndexModule
-
public final class IndexModule extends java.lang.ObjectIndexModule represents the central extension point for index level custom implementations like:Similarity- NewSimilarityimplementations can be registered throughaddSimilarity(String, TriFunction)while existing Providers can be referenced through Settings under theSIMILARITY_SETTINGS_PREFIXprefix along with the "type" value. For example, to reference theBM25Similarity, the configuration"index.similarity.my_similarity.type : "BM25"can be used.IndexStore- CustomIndexStoreinstances can be registered viaIndexStorePluginIndexEventListener- CustomIndexEventListenerinstances can be registered viaaddIndexEventListener(IndexEventListener)- Settings update listener - Custom settings update listener can be registered via
addSettingsUpdateConsumer(Setting, Consumer)
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interfaceIndexModule.IndexSearcherWrapperFactoryFactory for creating newIndexSearcherWrapperinstancesstatic classIndexModule.Type
-
Field Summary
Fields Modifier and Type Field Description static Setting<java.lang.Boolean>INDEX_QUERY_CACHE_ENABLED_SETTINGstatic Setting<java.lang.Boolean>INDEX_QUERY_CACHE_EVERYTHING_SETTINGstatic Setting<java.util.List<java.lang.String>>INDEX_STORE_PRE_LOAD_SETTINGOn which extensions to load data into the file-system cache upon opening of files.static Setting<java.lang.String>INDEX_STORE_TYPE_SETTINGstatic Setting<java.lang.Boolean>NODE_STORE_ALLOW_MMAPstatic Setting<java.lang.Boolean>NODE_STORE_ALLOW_MMAPFSstatic java.lang.StringSIMILARITY_SETTINGS_PREFIX
-
Constructor Summary
Constructors Constructor Description IndexModule(IndexSettings indexSettings, AnalysisRegistry analysisRegistry, EngineFactory engineFactory, java.util.Map<java.lang.String,java.util.function.Function<IndexSettings,IndexStore>> indexStoreFactories)Construct the index module for the index with the specified index settings.
-
Method Summary
Modifier and Type Method Description voidaddIndexEventListener(IndexEventListener listener)Adds anIndexEventListenerfor this index.voidaddIndexOperationListener(IndexingOperationListener listener)Adds anIndexingOperationListenerfor this index.voidaddSearchOperationListener(SearchOperationListener listener)Adds anSearchOperationListenerfor this index.<T> voidaddSettingsUpdateConsumer(Setting<T> setting, java.util.function.Consumer<T> consumer)Adds a Setting and it's consumer for this index.<T> voidaddSettingsUpdateConsumer(Setting<T> setting, java.util.function.Consumer<T> consumer, java.util.function.Consumer<T> validator)Adds a Setting, it's consumer and validator for this index.voidaddSimilarity(java.lang.String name, TriFunction<Settings,Version,ScriptService,org.apache.lucene.search.similarities.Similarity> similarity)Registers the givenSimilaritywith the given name.static IndexModule.TypedefaultStoreType(boolean allowMmap)voidforceQueryCacheProvider(java.util.function.BiFunction<IndexSettings,IndicesQueryCache,QueryCache> queryCacheProvider)Forces a certain query cache to use instead of the default one.IndexgetIndex()Returns the index this module is associated withSettingsgetSettings()Returns the indexSettingsfor this indexstatic booleanisBuiltinType(java.lang.String storeType)MapperServicenewIndexMapperService(NamedXContentRegistry xContentRegistry, MapperRegistry mapperRegistry, ScriptService scriptService)creates a new mapper service to do administrative work like mapping updates.IndexServicenewIndexService(NodeEnvironment environment, NamedXContentRegistry xContentRegistry, IndexService.ShardStoreDeleter shardStoreDeleter, CircuitBreakerService circuitBreakerService, BigArrays bigArrays, ThreadPool threadPool, ScriptService scriptService, Client client, IndicesQueryCache indicesQueryCache, MapperRegistry mapperRegistry, IndicesFieldDataCache indicesFieldDataCache, NamedWriteableRegistry namedWriteableRegistry)voidsetSearcherWrapper(IndexModule.IndexSearcherWrapperFactory indexSearcherWrapperFactory)Sets aIndexModule.IndexSearcherWrapperFactorythat is called once the IndexService is fully constructed.
-
-
-
Field Detail
-
NODE_STORE_ALLOW_MMAPFS
public static final Setting<java.lang.Boolean> NODE_STORE_ALLOW_MMAPFS
-
NODE_STORE_ALLOW_MMAP
public static final Setting<java.lang.Boolean> NODE_STORE_ALLOW_MMAP
-
INDEX_STORE_TYPE_SETTING
public static final Setting<java.lang.String> INDEX_STORE_TYPE_SETTING
-
INDEX_STORE_PRE_LOAD_SETTING
public static final Setting<java.util.List<java.lang.String>> INDEX_STORE_PRE_LOAD_SETTING
On which extensions to load data into the file-system cache upon opening of files. This only works with the mmap directory, and even in that case is still best-effort only.
-
SIMILARITY_SETTINGS_PREFIX
public static final java.lang.String SIMILARITY_SETTINGS_PREFIX
- See Also:
- Constant Field Values
-
INDEX_QUERY_CACHE_ENABLED_SETTING
public static final Setting<java.lang.Boolean> INDEX_QUERY_CACHE_ENABLED_SETTING
-
INDEX_QUERY_CACHE_EVERYTHING_SETTING
public static final Setting<java.lang.Boolean> INDEX_QUERY_CACHE_EVERYTHING_SETTING
-
-
Constructor Detail
-
IndexModule
public IndexModule(IndexSettings indexSettings, AnalysisRegistry analysisRegistry, EngineFactory engineFactory, java.util.Map<java.lang.String,java.util.function.Function<IndexSettings,IndexStore>> indexStoreFactories)
Construct the index module for the index with the specified index settings. The index module contains extension points for plugins viaPluginsService.onIndexModule(IndexModule).- Parameters:
indexSettings- the index settingsanalysisRegistry- the analysis registryengineFactory- the engine factoryindexStoreFactories- the available store types
-
-
Method Detail
-
addSettingsUpdateConsumer
public <T> void addSettingsUpdateConsumer(Setting<T> setting, java.util.function.Consumer<T> consumer)
Adds a Setting and it's consumer for this index.
-
addSettingsUpdateConsumer
public <T> void addSettingsUpdateConsumer(Setting<T> setting, java.util.function.Consumer<T> consumer, java.util.function.Consumer<T> validator)
Adds a Setting, it's consumer and validator for this index.
-
getIndex
public Index getIndex()
Returns the index this module is associated with
-
addIndexEventListener
public void addIndexEventListener(IndexEventListener listener)
Adds anIndexEventListenerfor this index. All listeners added here are maintained for the entire index lifecycle on this node. Once an index is closed or deleted these listeners go out of scope.Note: an index might be created on a node multiple times. For instance if the last shard from an index is relocated to another node the internal representation will be destroyed which includes the registered listeners. Once the node holds at least one shard of an index all modules are reloaded and listeners are registered again. Listeners can't be unregistered they will stay alive for the entire time the index is allocated on a node.
-
addSearchOperationListener
public void addSearchOperationListener(SearchOperationListener listener)
Adds anSearchOperationListenerfor this index. All listeners added here are maintained for the entire index lifecycle on this node. Once an index is closed or deleted these listeners go out of scope.Note: an index might be created on a node multiple times. For instance if the last shard from an index is relocated to another node the internal representation will be destroyed which includes the registered listeners. Once the node holds at least one shard of an index all modules are reloaded and listeners are registered again. Listeners can't be unregistered they will stay alive for the entire time the index is allocated on a node.
-
addIndexOperationListener
public void addIndexOperationListener(IndexingOperationListener listener)
Adds anIndexingOperationListenerfor this index. All listeners added here are maintained for the entire index lifecycle on this node. Once an index is closed or deleted these listeners go out of scope.Note: an index might be created on a node multiple times. For instance if the last shard from an index is relocated to another node the internal representation will be destroyed which includes the registered listeners. Once the node holds at least one shard of an index all modules are reloaded and listeners are registered again. Listeners can't be unregistered they will stay alive for the entire time the index is allocated on a node.
-
addSimilarity
public void addSimilarity(java.lang.String name, TriFunction<Settings,Version,ScriptService,org.apache.lucene.search.similarities.Similarity> similarity)Registers the givenSimilaritywith the given name. The function takes as parameters:- settings for this similarity
- version of Elasticsearch when the index was created
- ScriptService, for script-based similarities
- Parameters:
name- Name of the SimilarityProvidersimilarity- SimilarityProvider to register
-
setSearcherWrapper
public void setSearcherWrapper(IndexModule.IndexSearcherWrapperFactory indexSearcherWrapperFactory)
Sets aIndexModule.IndexSearcherWrapperFactorythat is called once the IndexService is fully constructed. Note: this method can only be called once per index. Multiple wrappers are not supported.
-
isBuiltinType
public static boolean isBuiltinType(java.lang.String storeType)
-
defaultStoreType
public static IndexModule.Type defaultStoreType(boolean allowMmap)
-
newIndexService
public IndexService newIndexService(NodeEnvironment environment, NamedXContentRegistry xContentRegistry, IndexService.ShardStoreDeleter shardStoreDeleter, CircuitBreakerService circuitBreakerService, BigArrays bigArrays, ThreadPool threadPool, ScriptService scriptService, Client client, IndicesQueryCache indicesQueryCache, MapperRegistry mapperRegistry, IndicesFieldDataCache indicesFieldDataCache, NamedWriteableRegistry namedWriteableRegistry) throws java.io.IOException
- Throws:
java.io.IOException
-
newIndexMapperService
public MapperService newIndexMapperService(NamedXContentRegistry xContentRegistry, MapperRegistry mapperRegistry, ScriptService scriptService) throws java.io.IOException
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.- Throws:
java.io.IOException
-
forceQueryCacheProvider
public void forceQueryCacheProvider(java.util.function.BiFunction<IndexSettings,IndicesQueryCache,QueryCache> queryCacheProvider)
Forces a certain query cache to use instead of the default one. If this is set and query caching is not disabled withindex.queries.cache.enabled, then the given provider will be used. NOTE: this can only be set once- See Also:
INDEX_QUERY_CACHE_ENABLED_SETTING
-
-