public final class IndexModule
extends java.lang.Object
SimilarityProvider
- New SimilarityProvider
implementations can be registered through
addSimilarity(String, BiFunction)
while existing Providers can be referenced through Settings under the
SIMILARITY_SETTINGS_PREFIX
prefix along with the "type" value. For example, to reference the
BM25SimilarityProvider
, the configuration "index.similarity.my_similarity.type : "BM25" can be used.IndexStore
- Custom IndexStore
instances can be registered via addIndexStore(String, BiFunction)
IndexEventListener
- Custom IndexEventListener
instances can be registered via
addIndexEventListener(IndexEventListener)
addSettingsUpdateConsumer(Setting, Consumer)
Modifier and Type | Class and Description |
---|---|
static interface |
IndexModule.IndexSearcherWrapperFactory
Factory for creating new
IndexSearcherWrapper instances |
static class |
IndexModule.Type |
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
INDEX_QUERY_CACHE |
static Setting<java.lang.Boolean> |
INDEX_QUERY_CACHE_EVERYTHING_SETTING |
static Setting<java.lang.String> |
INDEX_QUERY_CACHE_TYPE_SETTING |
static Setting<java.lang.String> |
INDEX_STORE_TYPE_SETTING |
static java.lang.String |
NONE_QUERY_CACHE |
static java.lang.String |
SIMILARITY_SETTINGS_PREFIX |
Constructor and Description |
---|
IndexModule(IndexSettings indexSettings,
IndexStoreConfig indexStoreConfig,
AnalysisRegistry analysisRegistry) |
Modifier and Type | Method and Description |
---|---|
void |
addIndexEventListener(IndexEventListener listener)
Adds an
IndexEventListener for this index. |
void |
addIndexOperationListener(IndexingOperationListener listener)
Adds an
IndexingOperationListener for this index. |
void |
addIndexStore(java.lang.String type,
java.util.function.BiFunction<IndexSettings,IndexStoreConfig,IndexStore> provider)
Adds an
IndexStore type to this index module. |
void |
addSearchOperationListener(SearchOperationListener listener)
Adds an
SearchOperationListener 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.
|
void |
addSimilarity(java.lang.String name,
java.util.function.BiFunction<java.lang.String,Settings,SimilarityProvider> similarity)
Registers the given
SimilarityProvider with the given name |
void |
forceQueryCacheType(java.lang.String type)
Forces a certain query cache type.
|
Index |
getIndex()
Returns the index this module is associated with
|
Settings |
getSettings()
Returns the index
Settings for this index |
IndexService |
newIndexService(NodeEnvironment environment,
IndexService.ShardStoreDeleter shardStoreDeleter,
NodeServicesProvider servicesProvider,
IndicesQueryCache indicesQueryCache,
MapperRegistry mapperRegistry,
IndicesFieldDataCache indicesFieldDataCache) |
void |
registerQueryCache(java.lang.String name,
java.util.function.BiFunction<IndexSettings,IndicesQueryCache,QueryCache> provider)
Registers a
QueryCache provider for a given name |
void |
setSearcherWrapper(IndexModule.IndexSearcherWrapperFactory indexSearcherWrapperFactory)
Sets a
IndexModule.IndexSearcherWrapperFactory that is called once the IndexService
is fully constructed. |
public static final Setting<java.lang.String> INDEX_STORE_TYPE_SETTING
public static final java.lang.String SIMILARITY_SETTINGS_PREFIX
public static final java.lang.String INDEX_QUERY_CACHE
public static final java.lang.String NONE_QUERY_CACHE
public static final Setting<java.lang.String> INDEX_QUERY_CACHE_TYPE_SETTING
public static final Setting<java.lang.Boolean> INDEX_QUERY_CACHE_EVERYTHING_SETTING
public IndexModule(IndexSettings indexSettings, IndexStoreConfig indexStoreConfig, AnalysisRegistry analysisRegistry)
public <T> void addSettingsUpdateConsumer(Setting<T> setting, java.util.function.Consumer<T> consumer)
public Index getIndex()
public void addIndexEventListener(IndexEventListener listener)
IndexEventListener
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.
public void addSearchOperationListener(SearchOperationListener listener)
SearchOperationListener
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.
public void addIndexOperationListener(IndexingOperationListener listener)
IndexingOperationListener
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.
public void addIndexStore(java.lang.String type, java.util.function.BiFunction<IndexSettings,IndexStoreConfig,IndexStore> provider)
IndexStore
type to this index module. Typically stores are registered with a reference to
it's constructor:
indexModule.addIndexStore("my_store_type", MyStore::new);
type
- the type to registerprovider
- the instance provider / factory methodpublic void addSimilarity(java.lang.String name, java.util.function.BiFunction<java.lang.String,Settings,SimilarityProvider> similarity)
SimilarityProvider
with the given namename
- Name of the SimilarityProvidersimilarity
- SimilarityProvider to registerpublic void registerQueryCache(java.lang.String name, java.util.function.BiFunction<IndexSettings,IndicesQueryCache,QueryCache> provider)
QueryCache
provider for a given namename
- the providers / caches nameprovider
- the provider instancepublic void setSearcherWrapper(IndexModule.IndexSearcherWrapperFactory indexSearcherWrapperFactory)
IndexModule.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.public IndexService newIndexService(NodeEnvironment environment, IndexService.ShardStoreDeleter shardStoreDeleter, NodeServicesProvider servicesProvider, IndicesQueryCache indicesQueryCache, MapperRegistry mapperRegistry, IndicesFieldDataCache indicesFieldDataCache) throws java.io.IOException
java.io.IOException
public void forceQueryCacheType(java.lang.String type)
INDEX_QUERY_CACHE_TYPE_SETTING