Interface IndexerQueryContextFactory<T extends IndexerQueryContext>
- All Known Implementing Classes:
DefaultIndexerQueryContextFactory
public interface IndexerQueryContextFactory<T extends IndexerQueryContext>
Implementations of this interface are responsible for creating and destroying instances of
IndexerQueryContext.
Code creating/destroying contexts should normally use the following pattern:
try
{
final IndexerQueryContext context = indexerQueryContextFactory.createContext(facetSearchConfig, indexedType, query,
queryParameters);
// call additional setters on the context object
indexerQueryContextFactory.initializeContext();
// put your logic here
indexerQueryContextFactory.destroyContext();
}
catch (final IndexerException | ... | RuntimeException exception)
{
indexerQueryContextFactory.destroyContext(exception);
throw exception;
}
-
Method Summary
Modifier and TypeMethodDescriptioncreateContext(FacetSearchConfig facetSearchConfig, IndexedType indexedType, String query, Map<String, Object> queryParameters) Creates a new indexer context and sets it as current.voidDestroys the current context.voiddestroyContext(Exception exception) Destroys the current context because an exception occurred.Returns the current context.voidInitializes the current context and executes the before index listeners (seeIndexerListener.beforeIndex(IndexerContext)).
-
Method Details
-
createContext
T createContext(FacetSearchConfig facetSearchConfig, IndexedType indexedType, String query, Map<String, Object> queryParameters) throws IndexerExceptionCreates a new indexer context and sets it as current.- Parameters:
facetSearchConfig- - the facet search configurationindexedType- - the indexed typequery- - the queryqueryParameters- - the query parameters- Returns:
- the new context
- Throws:
IndexerException- if an error occurs during the listeners execution
-
initializeContext
Initializes the current context and executes the before index listeners (seeIndexerListener.beforeIndex(IndexerContext)).- Throws:
IndexerException- if an error occurs during the listeners execution
-
getContext
T getContext()Returns the current context.- Returns:
- the current context
-
destroyContext
Destroys the current context. Before destroying an active context it executes the after query listeners (seeIndexerQueryListener.afterQuery(IndexerQueryContext)).- Throws:
IndexerException- if an error occurs during the listeners execution
-
destroyContext
Destroys the current context because an exception occurred. Before destroying an active context it executes the after query error listeners (seeIndexerQueryListener.afterQueryError(IndexerQueryContext)).
-