org.hibernate.search.spi

## Interface SearchIntegrator

- All Superinterfaces:
    AutoCloseable
  All Known Subinterfaces:
    ExtendedSearchIntegrator, ExtendedSearchIntegratorWithShareableState
  All Known Implementing Classes:
    ImmutableSearchFactory, MutableSearchFactory

      public interface SearchIntegrator
      extends AutoCloseable

  This contract gives access to lower level APIs of Hibernate Search for frameworks integrating with it. Frameworks should not expose this as public API though, but expose a simplified view; for example the Hibernate Search ORM module expose the `org.hibernate.search.SearchFactory` contract to its clients.
  Author:
    Emmanuel Bernard, Sanne Grinovero

- - ### Method Summary

    All Methods Instance Methods Abstract Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `addClasses(Class<?>... classes)` Add the following classes to the SearchIntegrator.
    `QueryContextBuilder` | `buildQueryBuilder()`
    `void` | `close()` Shuts down all workers and releases all resources.
    `HSQuery` | `createHSQuery(Query fullTextQuery, Class<?>... entityTypes)` Return an Hibernate Search query object.
    `HSQuery` | `createHSQuery(Query fullTextQuery, IndexedTypeMap<CustomTypeMetadata> types)` Return an Hibernate Search query object.
    `OperationDispatcher` | `createRemoteOperationDispatcher(Predicate<IndexManager> indexManagerFilter)`
    `Analyzer` | `getAnalyzer(IndexedTypeIdentifier typeId)` Retrieves the scoped analyzer for a given indexed type.
    `Analyzer` | `getAnalyzer(String name)` Retrieve an analyzer instance by its definition name
    `TimeoutExceptionFactory` | `getDefaultTimeoutExceptionFactory()` Useful if you need to create custom exception types to represent query timeouts.
    `ErrorHandler` | `getErrorHandler()` Used to catch exceptions in all synchronous operations; but default they are logged, the user can configure alternative error management means.
    `EntityIndexBinding` | `getIndexBinding(IndexedTypeIdentifier entityType)` Returns the entity to index binding for the given type.
    `IndexedTypeMap<EntityIndexBinding>` | `getIndexBindings()` Returns a map of all known entity index binding (indexed entities) keyed against the indexed type
    `IndexedTypeDescriptor` | `getIndexedTypeDescriptor(IndexedTypeIdentifier typeId)` Returns a descriptor for the specified entity type describing its indexed state.
    `IndexedTypeSet` | `getIndexedTypeIdentifiers()` Returns the set of currently indexed types.
    `IndexingMode` | `getIndexingMode()`
    `IndexManager` | `getIndexManager(String indexName)` Get an `IndexManager` using the name
    `IndexReaderAccessor` | `getIndexReaderAccessor()` Provides access to the IndexReader API
    `ServiceManager` | `getServiceManager()` Returns the service manager.
    `Statistics` | `getStatistics()` Retrieve the statistics instance for this factory.
    `Worker` | `getWorker()` The Worker is the entry point to apply writes and updates to the indexes.
    `LuceneWorkSerializer` | `getWorkSerializer()`
    `boolean` | `isStopped()`
    `BatchBackend` | `makeBatchBackend(MassIndexerProgressMonitor progressMonitor)`
    `void` | `optimize()` Optimize all indexes
    `void` | `optimize(IndexedTypeIdentifier entityType)` Optimize the index holding `entityType`
    `<T> T` | `unwrap(Class<T> cls)` Unwraps some internal Hibernate Search types.

- - ### Method Detail

    - #### getIndexBindings

          IndexedTypeMap<EntityIndexBinding> getIndexBindings()

      Returns a map of all known entity index binding (indexed entities) keyed against the indexed type
      Returns:
        a map of all known entity index binding (indexed entities) keyed against the indexed type. The empty map is returned if there are no indexed types.

    - #### getIndexBinding

          EntityIndexBinding getIndexBinding(IndexedTypeIdentifier entityType)

      Returns the entity to index binding for the given type.
      Parameters:
        `entityType` - the type for which to retrieve the binding
      Returns:
        the entity to index binding for the given type. `null` is returned for types which are unindexed or unknown.

    - #### addClasses

          void addClasses(Class<?>... classes)

      Add the following classes to the SearchIntegrator. If these classes are new to the SearchIntegrator this will trigger a reconfiguration.
      Parameters:
        `classes` - the classes to add to the `SearchIntegrator`

    - #### createHSQuery

          HSQuery createHSQuery(Query fullTextQuery,
                                Class<?>... entityTypes)

      Return an Hibernate Search query object.

      This method DOES support non-Lucene backends (e.g. Elasticsearch).

      The returned object uses fluent APIs to define additional query settings.

      Be aware that some backends may not implement `HSQuery.luceneQuery(Query)`, in which case the query provided here cannot be overridden.

      Parameters:
        `fullTextQuery` - the full-text engine query
        `entityTypes` - the targeted entity types
      Returns:
        an Hibernate Search query object

    - #### createHSQuery

          HSQuery createHSQuery(Query fullTextQuery,
                                IndexedTypeMap<CustomTypeMetadata> types)

      Return an Hibernate Search query object.

      This method DOES support non-Lucene backends (e.g. Elasticsearch).

      The returned object uses fluent APIs to define additional query settings.

      Be aware that some backends may not implement `HSQuery.luceneQuery(Query)`, in which case the query provided here cannot be overridden.

      Parameters:
        `fullTextQuery` - the full-text engine query
        `types` - the targeted entity types, mapped to (potentially null) overridden metadata
      Returns:
        an Hibernate Search query object

    - #### isStopped

          boolean isStopped()

      Returns:
        true if the SearchIntegrator was stopped

    - #### getErrorHandler

          ErrorHandler getErrorHandler()

      Used to catch exceptions in all synchronous operations; but default they are logged, the user can configure alternative error management means.
      Returns:
        the configured ErrorHandler, global to the SearchIntegrator

    - #### getDefaultTimeoutExceptionFactory

          TimeoutExceptionFactory getDefaultTimeoutExceptionFactory()

      Useful if you need to create custom exception types to represent query timeouts.
      Returns:
        the configured TimeoutExceptionFactory

    - #### optimize

          void optimize()

      Optimize all indexes

    - #### optimize

          void optimize(IndexedTypeIdentifier entityType)

      Optimize the index holding `entityType`
      Parameters:
        `entityType` - the entity type (index) to optimize

    - #### getAnalyzer

          Analyzer getAnalyzer(String name)

      Retrieve an analyzer instance by its definition name
      Parameters:
        `name` - the name of the analyzer
      Returns:
        analyzer with the specified name
      Throws:
        `SearchException` - if the definition name is unknown

    - #### getAnalyzer

          Analyzer getAnalyzer(IndexedTypeIdentifier typeId)

      Retrieves the scoped analyzer for a given indexed type.
      Parameters:
        `typeId` - The indexed type identifier for which to retrieve the analyzer.
      Returns:
        The scoped analyzer for the specified class.
      Throws:
        `IllegalArgumentException` - in case `clazz == null` or the specified class is not an indexed entity.

    - #### buildQueryBuilder

          QueryContextBuilder buildQueryBuilder()

      Returns:
        return a query builder providing a fluent API to create Lucene queries

    - #### getStatistics

          Statistics getStatistics()

      Retrieve the statistics instance for this factory.
      Returns:
        The statistics.

    - #### getIndexReaderAccessor

          IndexReaderAccessor getIndexReaderAccessor()

      Provides access to the IndexReader API
      Returns:
        the IndexReaderAccessor for this SearchIntegrator

    - #### getIndexedTypeDescriptor

          IndexedTypeDescriptor getIndexedTypeDescriptor(IndexedTypeIdentifier typeId)

      Returns a descriptor for the specified entity type describing its indexed state.
      Parameters:
        `typeId` - the identification of the indexed entity for which to retrieve the descriptor
      Returns:
        a non `null` `IndexedEntityDescriptor`. This method can also be called for non indexed types. To determine whether the entity is actually indexed `IndexedTypeDescriptor.isIndexed()` can be used.
      Throws:
        `IllegalArgumentException` - in case `entityType` is `null`

    - #### getIndexedTypeIdentifiers

          IndexedTypeSet getIndexedTypeIdentifiers()

      Returns the set of currently indexed types.
      Returns:
        the set of currently indexed types. This might be empty.

    - #### unwrap

          <T> T unwrap(Class<T> cls)

      Unwraps some internal Hibernate Search types. Currently, no public type is accessible. This method should not be used by users.
      Type Parameters:
        `T` - the type of the unwrapped object
      Parameters:
        `cls` - the class of the internal object to unwrap
      Returns:
        the unwrapped object

    - #### getServiceManager

          ServiceManager getServiceManager()

      Returns the service manager.
      Returns:
        Returns the service manager.

    - #### getWorker

          Worker getWorker()

      The Worker is the entry point to apply writes and updates to the indexes.
      Returns:
        the `Worker`

    - #### close

          void close()

      Shuts down all workers and releases all resources.
      Specified by:
        `close` in interface `AutoCloseable`

    - #### getIndexManager

          IndexManager getIndexManager(String indexName)

      Get an `IndexManager` using the name
      Parameters:
        `indexName` - the name of the `IndexManager`
      Returns:
        the selected `IndexManager`

    - #### getIndexingMode

          IndexingMode getIndexingMode()

      Returns:
        the current indexing strategy as specified via `Environment.INDEXING_STRATEGY`.

    - #### makeBatchBackend

          BatchBackend makeBatchBackend(MassIndexerProgressMonitor progressMonitor)

    - #### getWorkSerializer

          LuceneWorkSerializer getWorkSerializer()

    - #### createRemoteOperationDispatcher

          OperationDispatcher createRemoteOperationDispatcher(Predicate<IndexManager> indexManagerFilter)

      Parameters:
        `indexManagerFilter` - A predicate allowing to exclude index managers from dispatching. Works will not be applied to these index managers.
      Returns:
        An operation dispatcher allowing to insert works retrieved from remote sources (e.g. JMS or JGroups slaves), but only for index managers verifying the given predicate. This allows JMS or JGroups integrations to perform checks on index managers that wouldn't exist before the dispatch, in the case of dynamic sharding in particular.
      Experimental
        Operation dispatchers are under active development. You should be prepared for incompatible changes in future releases.

Copyright © 2006-2017 Red Hat, Inc. All Rights Reserved