Class IndexModule
- java.lang.Object
-
- org.elasticsearch.index.IndexModule
-
public final class IndexModule extends java.lang.Object
IndexModule represents the central extension point for index level custom implementations like:Similarity
- NewSimilarity
implementations can be registered throughaddSimilarity(String, TriFunction)
while existing Providers can be referenced through Settings under theSIMILARITY_SETTINGS_PREFIX
prefix along with the "type" value. For example, to reference theBM25Similarity
, the configuration"index.similarity.my_similarity.type : "BM25"
can be used.IndexStore
- CustomIndexStore
instances can be registered viaaddIndexStore(String, Function)
IndexEventListener
- CustomIndexEventListener
instances 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 interface
IndexModule.IndexSearcherWrapperFactory
Factory for creating newIndexSearcherWrapper
instancesstatic class
IndexModule.Type
-
Field Summary
Fields Modifier and Type Field Description static Setting<java.lang.Boolean>
INDEX_QUERY_CACHE_ENABLED_SETTING
static Setting<java.lang.Boolean>
INDEX_QUERY_CACHE_EVERYTHING_SETTING
static 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.static Setting<java.lang.String>
INDEX_STORE_TYPE_SETTING
static java.lang.String
SIMILARITY_SETTINGS_PREFIX
-
Constructor Summary
Constructors Constructor Description IndexModule(IndexSettings indexSettings, AnalysisRegistry analysisRegistry, EngineFactory engineFactory)
Construct the index module for the index with the specified index settings.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addIndexEventListener(IndexEventListener listener)
Adds anIndexEventListener
for this index.void
addIndexOperationListener(IndexingOperationListener listener)
Adds anIndexingOperationListener
for this index.void
addIndexStore(java.lang.String type, java.util.function.Function<IndexSettings,IndexStore> provider)
Adds anIndexStore
type to this index module.void
addSearchOperationListener(SearchOperationListener listener)
Adds anSearchOperationListener
for this index.<T> void
addSettingsUpdateConsumer(Setting<T> setting, java.util.function.Consumer<T> consumer)
Adds a Setting and it's consumer for this index.<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.void
addSimilarity(java.lang.String name, TriFunction<Settings,Version,ScriptService,org.apache.lucene.search.similarities.Similarity> similarity)
Registers the givenSimilarity
with the given name.void
forceQueryCacheProvider(java.util.function.BiFunction<IndexSettings,IndicesQueryCache,QueryCache> queryCacheProvider)
Forces a certain query cache to use instead of the default one.Index
getIndex()
Returns the index this module is associated withSettings
getSettings()
Returns the indexSettings
for this indexMapperService
newIndexMapperService(NamedXContentRegistry xContentRegistry, MapperRegistry mapperRegistry, ScriptService scriptService)
creates a new mapper service to do administrative work like mapping updates.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)
void
setSearcherWrapper(IndexModule.IndexSearcherWrapperFactory indexSearcherWrapperFactory)
Sets aIndexModule.IndexSearcherWrapperFactory
that is called once the IndexService is fully constructed.
-
-
-
Field Detail
-
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)
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 factory
-
-
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 anIndexEventListener
for 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 anSearchOperationListener
for 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 anIndexingOperationListener
for 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.
-
addIndexStore
public void addIndexStore(java.lang.String type, java.util.function.Function<IndexSettings,IndexStore> provider)
Adds anIndexStore
type to this index module. Typically stores are registered with a reference to it's constructor:indexModule.addIndexStore("my_store_type", MyStore::new);
- Parameters:
type
- the type to registerprovider
- the instance provider / factory method
-
addSimilarity
public void addSimilarity(java.lang.String name, TriFunction<Settings,Version,ScriptService,org.apache.lucene.search.similarities.Similarity> similarity)
Registers the givenSimilarity
with 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.IndexSearcherWrapperFactory
that is called once the IndexService is fully constructed. Note: this method can only be called once per index. Multiple wrappers are not supported.
-
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
-
-