A
query preprocessor modifies the native SolrQuery
object
right before it is sent to the Solr server for processing.
Procedure
- Create a class that:
- Extends from the AbstractSolrSearchQueryPreprocessor class,
and
- Implements the SearchQueryPreprocessor interface.
- Implement the constructor method, which takes a component
identifier as a string input parameter. Typically, component-specific
logic is initialized here.
- Implement the
invoke
method which takes
the SelectionCriteria
object and an object array
as input parameters. This SelectionCriteria
object
is a Java representation of the original search expression, where
search criteria is stored as a control parameter object.The
object array contains the native
SolrQuery
object
which is initialized by:
super.invoke(selectionCriteria, queryRequestObjects);
There are two instance variables that can be used:
- iSelectionCriteria
- Java representation of the original search expression.
- iSolrQuery
- Java representation of native search query request objects.
- Helper methods are available from
its abstract class which can be used for retrieving from the control
parameters:
Example
The following download contains a code sample for creating
a custom query preprocessor: