A
query postprocessor modifies the physical DataObject, SolrEntityContainerImpl
,
immediately after the QueryResponse
is returned from
the Solr server.
Procedure
- Create a class that:
- Extends from the AbstractSolrSearchQueryPostprocessor class,
and
- Implements the SearchQueryPostprocessor 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
QueryResponse
object
which is initialized by:
super.invoke(selectionCriteria, queryResponseObjects);
- 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 how a custom postprocessor is configured in the
wc-search.xml file,
and how it is used to add more data into the final response object.