Class IndexModule
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.IndexStorePlugin.DirectoryFactory- CustomIndexStorePlugin.DirectoryFactoryinstances 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 -
Field Summary
FieldsModifier and TypeFieldDescriptionOn which extensions to load data into the file-system cache upon opening of files.static String -
Constructor Summary
ConstructorsConstructorDescriptionIndexModule(IndexSettings indexSettings, AnalysisRegistry analysisRegistry, EngineFactory engineFactory, Map<String,IndexStorePlugin.DirectoryFactory> directoryFactories, BooleanSupplier allowExpensiveQueries, IndexNameExpressionResolver expressionResolver, Map<String,IndexStorePlugin.RecoveryStateFactory> recoveryStateFactories)Construct the index module for the index with the specified index settings. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddIndexEventListener(IndexEventListener listener)Adds anIndexEventListenerfor this index.voidAdds anIndexingOperationListenerfor this index.voidAdds anSearchOperationListenerfor this index.<T> voidaddSettingsUpdateConsumer(Setting<T> setting, Consumer<T> consumer)Adds a Setting and it's consumer for this index.<T> voidaddSettingsUpdateConsumer(Setting<T> setting, Consumer<T> consumer, Consumer<T> validator)Adds a Setting, it's consumer and validator for this index.voidaddSimilarity(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(BiFunction<IndexSettings,IndicesQueryCache,QueryCache> queryCacheProvider)Forces a certain query cache to use instead of the default one.getIndex()Returns the index this module is associated withReturns the indexSettingsfor this indexstatic booleanisBuiltinType(String storeType)newIndexMapperService(org.elasticsearch.common.xcontent.NamedXContentRegistry xContentRegistry, MapperRegistry mapperRegistry, ScriptService scriptService)creates a new mapper service to do administrative work like mapping updates.newIndexService(IndexService.IndexCreationContext indexCreationContext, NodeEnvironment environment, org.elasticsearch.common.xcontent.NamedXContentRegistry xContentRegistry, IndexService.ShardStoreDeleter shardStoreDeleter, CircuitBreakerService circuitBreakerService, BigArrays bigArrays, ThreadPool threadPool, ScriptService scriptService, ClusterService clusterService, Client client, IndicesQueryCache indicesQueryCache, MapperRegistry mapperRegistry, IndicesFieldDataCache indicesFieldDataCache, NamedWriteableRegistry namedWriteableRegistry, BooleanSupplier idFieldDataEnabled, ValuesSourceRegistry valuesSourceRegistry, IndexStorePlugin.IndexFoldersDeletionListener indexFoldersDeletionListener, Map<String,IndexStorePlugin.SnapshotCommitSupplier> snapshotCommitSuppliers)voidsetReaderWrapper(Function<IndexService,org.elasticsearch.core.CheckedFunction<org.apache.lucene.index.DirectoryReader,org.apache.lucene.index.DirectoryReader,IOException>> indexReaderWrapperFactory)Sets the factory for creating newDirectoryReaderwrapper instances.
-
Field Details
-
NODE_STORE_ALLOW_MMAP
-
INDEX_STORE_TYPE_SETTING
-
INDEX_RECOVERY_TYPE_SETTING
-
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
- See Also:
- Constant Field Values
-
INDEX_QUERY_CACHE_ENABLED_SETTING
-
INDEX_QUERY_CACHE_EVERYTHING_SETTING
-
DEFAULT_SNAPSHOT_COMMIT_SUPPLIER
-
-
Constructor Details
-
IndexModule
public IndexModule(IndexSettings indexSettings, AnalysisRegistry analysisRegistry, EngineFactory engineFactory, Map<String,IndexStorePlugin.DirectoryFactory> directoryFactories, BooleanSupplier allowExpensiveQueries, IndexNameExpressionResolver expressionResolver, Map<String,IndexStorePlugin.RecoveryStateFactory> recoveryStateFactories)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 factorydirectoryFactories- the available store types
-
-
Method Details
-
addSettingsUpdateConsumer
Adds a Setting and it's consumer for this index. -
addSettingsUpdateConsumer
public <T> void addSettingsUpdateConsumer(Setting<T> setting, Consumer<T> consumer, Consumer<T> validator)Adds a Setting, it's consumer and validator for this index. -
getSettings
Returns the indexSettingsfor this index -
getIndex
Returns the index this module is associated with -
addIndexEventListener
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
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
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(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
-
setReaderWrapper
public void setReaderWrapper(Function<IndexService,org.elasticsearch.core.CheckedFunction<org.apache.lucene.index.DirectoryReader,org.apache.lucene.index.DirectoryReader,IOException>> indexReaderWrapperFactory)Sets the factory for creating newDirectoryReaderwrapper instances. The factory (Function) is called once the IndexService is fully constructed. NOTE: this method can only be called once per index. Multiple wrappers are not supported.The
CheckedFunctionis invoked each time aEngine.Searcheris requested to do an operation, for example search, and must return a new directory reader wrapping the provided directory reader or if no wrapping was performed the provided directory reader. The wrapped reader can filter out document just like delete documents etc. but must not change any term or document content. NOTE: The index reader wrapper (CheckedFunction) has a per-request lifecycle, must delegateIndexReader.getReaderCacheHelper(),LeafReader.getCoreCacheHelper()and must be an instance ofFilterDirectoryReaderthat eventually exposes the original reader viaFilterDirectoryReader.getDelegate(). The returned reader is closed once it goes out of scope. -
isBuiltinType
-
defaultStoreType
-
newIndexService
public IndexService newIndexService(IndexService.IndexCreationContext indexCreationContext, NodeEnvironment environment, org.elasticsearch.common.xcontent.NamedXContentRegistry xContentRegistry, IndexService.ShardStoreDeleter shardStoreDeleter, CircuitBreakerService circuitBreakerService, BigArrays bigArrays, ThreadPool threadPool, ScriptService scriptService, ClusterService clusterService, Client client, IndicesQueryCache indicesQueryCache, MapperRegistry mapperRegistry, IndicesFieldDataCache indicesFieldDataCache, NamedWriteableRegistry namedWriteableRegistry, BooleanSupplier idFieldDataEnabled, ValuesSourceRegistry valuesSourceRegistry, IndexStorePlugin.IndexFoldersDeletionListener indexFoldersDeletionListener, Map<String,IndexStorePlugin.SnapshotCommitSupplier> snapshotCommitSuppliers) throws IOException- Throws:
IOException
-
newIndexMapperService
public MapperService newIndexMapperService(org.elasticsearch.common.xcontent.NamedXContentRegistry xContentRegistry, MapperRegistry mapperRegistry, ScriptService scriptService) throws IOExceptioncreates 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:
IOException
-
forceQueryCacheProvider
public void forceQueryCacheProvider(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
-