org.hibernate.search.indexes.impl

## Class DefaultIndexReaderAccessor

- java.lang.Object
- - org.hibernate.search.indexes.impl.DefaultIndexReaderAccessor

- All Implemented Interfaces:
    IndexReaderAccessor

      public class DefaultIndexReaderAccessor
      extends Object
      implements IndexReaderAccessor

  Provides access to IndexReaders. IndexReaders opened through this service need to be closed using this service.
  Author:
    Sanne Grinovero (C) 2011 Red Hat Inc.

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `DefaultIndexReaderAccessor(ImmutableSearchFactory immutableSearchFactory)`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `close(IndexReader indexReader)` Closes IndexReader instances obtained using `IndexReaderAccessor.open(Class...)`
    `IndexReader` | `open(Class<?>... entities)` Opens an IndexReader on all indexes containing the entities passed as parameter.
    `IndexReader` | `open(IndexedTypeSet types)` This method is intended for integrators which use alternative entity mappings over annotated Class objects.
    `IndexReader` | `open(String... indexNames)` Opens an IndexReader on all named indexes.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### DefaultIndexReaderAccessor

          public DefaultIndexReaderAccessor(ImmutableSearchFactory immutableSearchFactory)

  - ### Method Detail

    - #### close

          public void close(IndexReader indexReader)

      Description copied from interface: `IndexReaderAccessor`
      Closes IndexReader instances obtained using `IndexReaderAccessor.open(Class...)`
      Specified by:
        `close` in interface `IndexReaderAccessor`
      Parameters:
        `indexReader` - the IndexReader to be closed

    - #### open

          public IndexReader open(Class<?>... entities)

      Description copied from interface: `IndexReaderAccessor`
      Opens an IndexReader on all indexes containing the entities passed as parameter. In the simplest case passing a single entity will map to a single index; if the entity uses a sharding strategy or if multiple entities using different index names are selected, the single IndexReader will act as a MultiReader on the aggregate of these indexes. This MultiReader is not filtered by Hibernate Search, so it might contain information relevant to different types as well.

      The returned IndexReader is read only; writing directly to the index is discouraged. If you need to write to the index use the `SearchIntegrator.getWorker()` to queue change operations to the backend.

      The IndexReader should not be closed in other ways except being returned to this instance via `IndexReaderAccessor.close(IndexReader)`.

      Specified by:
        `open` in interface `IndexReaderAccessor`
      Parameters:
        `entities` - the entity types for which to return a (multi)reader
      Returns:
        an IndexReader containing at least all listed entities

    - #### open

          public IndexReader open(IndexedTypeSet types)

      Description copied from interface: `IndexReaderAccessor`
      This method is intended for integrators which use alternative entity mappings over annotated Class objects.
      Specified by:
        `open` in interface `IndexReaderAccessor`
      Parameters:
        `types` - the entity types for which to return a (multi)reader
      Returns:
        an IndexReader containing at least all listed entities

    - #### open

          public IndexReader open(String... indexNames)

      Description copied from interface: `IndexReaderAccessor`
      Opens an IndexReader on all named indexes. A single name can be provided, or multiple. In the case of multiple names it still returns a single IndexReader instance, but this will make it possible to run queries on the combination of each index.
      Specified by:
        `open` in interface `IndexReaderAccessor`
      Parameters:
        `indexNames` - At least one IndexManager name.
      Returns:
        an IndexReader instance.

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