Class IndexModule

java.lang.Object
org.elasticsearch.index.IndexModule

public final class IndexModule extends Object
IndexModule represents the central extension point for index level custom implementations like:
  • Field Details

    • NODE_STORE_ALLOW_MMAP

      public static final Setting<Boolean> NODE_STORE_ALLOW_MMAP
    • INDEX_STORE_TYPE_SETTING

      public static final Setting<String> INDEX_STORE_TYPE_SETTING
    • INDEX_RECOVERY_TYPE_SETTING

      public static final Setting<String> INDEX_RECOVERY_TYPE_SETTING
    • INDEX_STORE_PRE_LOAD_SETTING

      public static final Setting<List<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 String SIMILARITY_SETTINGS_PREFIX
      See Also:
      Constant Field Values
    • INDEX_QUERY_CACHE_ENABLED_SETTING

      public static final Setting<Boolean> INDEX_QUERY_CACHE_ENABLED_SETTING
    • INDEX_QUERY_CACHE_EVERYTHING_SETTING

      public static final Setting<Boolean> INDEX_QUERY_CACHE_EVERYTHING_SETTING
    • DEFAULT_SNAPSHOT_COMMIT_SUPPLIER

      public static final IndexStorePlugin.SnapshotCommitSupplier DEFAULT_SNAPSHOT_COMMIT_SUPPLIER
  • Constructor Details

  • Method Details

    • addSettingsUpdateConsumer

      public <T> void addSettingsUpdateConsumer(Setting<T> setting, Consumer<T> consumer)
      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

      public Settings getSettings()
      Returns the index Settings for this index
    • getIndex

      public Index getIndex()
      Returns the index this module is associated with
    • addIndexEventListener

      public void addIndexEventListener(IndexEventListener listener)
      Adds an 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.

    • addSearchOperationListener

      public void addSearchOperationListener(SearchOperationListener listener)
      Adds an 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.

    • addIndexOperationListener

      public void addIndexOperationListener(IndexingOperationListener listener)
      Adds an 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.

    • addSimilarity

      public void addSimilarity(String name, TriFunction<Settings,Version,ScriptService,org.apache.lucene.search.similarities.Similarity> similarity)
      Registers the given Similarity 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 SimilarityProvider
      similarity - 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 new DirectoryReader wrapper 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 CheckedFunction is invoked each time a Engine.Searcher is 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 delegate IndexReader.getReaderCacheHelper(), LeafReader.getCoreCacheHelper() and must be an instance of FilterDirectoryReader that eventually exposes the original reader via FilterDirectoryReader.getDelegate(). The returned reader is closed once it goes out of scope.

    • isBuiltinType

      public static boolean isBuiltinType(String storeType)
    • defaultStoreType

      public static IndexModule.Type defaultStoreType(boolean allowMmap)
    • 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 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:
      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 with index.queries.cache.enabled, then the given provider will be used. NOTE: this can only be set once
      See Also:
      INDEX_QUERY_CACHE_ENABLED_SETTING