org.hibernate.search.indexes
Interface IndexReaderAccessor

All Known Implementing Classes:
DefaultIndexReaderAccessor

public interface IndexReaderAccessor

The IndexReaderAccessor exposes IndexReaders directly, making it possible to query the Lucene indexes directly bypassing Hibernate Search.

The returned IndexReader instances are always read-only and must be closed using the close(IndexReader) method on this same instance.

Note: this API is intended for power users intending to extract information directly.

Author:
Sanne Grinovero (C) 2011 Red Hat Inc.

Method Summary
 void close(org.apache.lucene.index.IndexReader indexReader)
          Closes IndexReader instances obtained using open(Class...)
 org.apache.lucene.index.IndexReader open(Class<?>... entities)
          Opens an IndexReader on all indexes containing the entities passed as parameter.
 org.apache.lucene.index.IndexReader open(String... indexNames)
          Opens an IndexReader on all named indexes.
 

Method Detail

open

org.apache.lucene.index.IndexReader open(Class<?>... entities)
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 SearchFactoryIntegrator.getWorker() to queue change operations to the backend.

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

Parameters:
entities - the entity types for which to return a (multi)reader
Returns:
an IndexReader containing at least all listed entities
Throws:
IllegalArgumentException - if one of the specified classes is not indexed

open

org.apache.lucene.index.IndexReader open(String... indexNames)
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.

Parameters:
indexNames - At least one IndexManager name.
Returns:
an IndexReader instance.
Throws:
SearchException - if the index manager to which the named index belongs failed to start

close

void close(org.apache.lucene.index.IndexReader indexReader)
Closes IndexReader instances obtained using open(Class...)

Parameters:
indexReader - the IndexReader to be closed


Copyright © 2006-2012 Red Hat Middleware, LLC. All Rights Reserved