public abstract class FacetResultsHandler extends Object
The facet results handler provided by the FacetRequest
to
a FacetsAccumulator
.
First it is used by FacetsAccumulator
to obtain a temporary
facet result for each partition and to merge results of several partitions.
Later the accumulator invokes the handler to render the results, creating
FacetResult
objects.
Last the accumulator invokes the handler to label final results.
Modifier and Type | Field and Description |
---|---|
protected FacetRequest |
facetRequest
Facet request served by this handler.
|
protected TaxonomyReader |
taxonomyReader
Taxonomy for which facets are handled
|
Constructor and Description |
---|
FacetResultsHandler(TaxonomyReader taxonomyReader,
FacetRequest facetRequest)
Create a faceted search handler.
|
Modifier and Type | Method and Description |
---|---|
abstract IntermediateFacetResult |
fetchPartitionResult(FacetArrays arrays,
int offset)
Fetch results of a single partition, given facet arrays for that partition,
and based on the matching documents and faceted search parameters.
|
FacetRequest |
getFacetRequest()
Return the facet request served by this handler.
|
TaxonomyReader |
getTaxonomyReader()
Return taxonomy reader used for current facets accumulation operation.
|
protected boolean |
isSelfPartition(int ordinal,
FacetArrays facetArrays,
int offset)
Check if an array contains the partition which contains ordinal
|
abstract void |
labelResult(FacetResult facetResult)
Label results according to settings in
FacetRequest ,
such as FacetRequest.getNumLabel() . |
abstract IntermediateFacetResult |
mergeResults(IntermediateFacetResult... tmpResults)
Merge results of several facet partitions.
|
abstract FacetResult |
rearrangeFacetResult(FacetResult facetResult)
Perform any rearrangement as required on a facet result that has changed after
it was rendered.
|
abstract FacetResult |
renderFacetResult(IntermediateFacetResult tmpResult)
Create a facet result from the temporary result.
|
protected final TaxonomyReader taxonomyReader
protected final FacetRequest facetRequest
public FacetResultsHandler(TaxonomyReader taxonomyReader, FacetRequest facetRequest)
taxonomyReader
- See getTaxonomyReader()
.facetRequest
- See getFacetRequest()
.public abstract IntermediateFacetResult fetchPartitionResult(FacetArrays arrays, int offset) throws IOException
arrays
- facet arrays for the certain partitionoffset
- offset in input arrays where partition startsfacetRequest
, requests an
illegal FacetResult, like, e.g., a root node category path that
does not exist in constructor parameter taxonomyReader
.IOException
- on errorpublic abstract IntermediateFacetResult mergeResults(IntermediateFacetResult... tmpResults) throws IOException, ClassCastException, IllegalArgumentException
IntermediateFacetResult
must be ones
that were created by this handler otherwise a ClassCastException
is
thrown. In addition, all passed IntermediateFacetResult
must have
the same FacetRequest
otherwise an IllegalArgumentException
is thrown.tmpResults
- one or more temporary results created by this
handler.IOException
- on error.ClassCastException
- if the temporary result passed was not created
by this handlerIllegalArgumentException
- if passed facetResults
do not
have the same FacetRequest
IntermediateFacetResult.getFacetRequest()
public abstract FacetResult renderFacetResult(IntermediateFacetResult tmpResult) throws IOException
tmpResult
- temporary result to be rendered as a FacetResult
IOException
- on error.public abstract FacetResult rearrangeFacetResult(FacetResult facetResult)
Possible use case: a sampling facets accumulator invoked another other facets accumulator on a sample set of documents, obtained rendered facet results, fixed their counts, and now it is needed to sort the results differently according to the fixed counts.
facetResult
- result to be rearranged.FacetResultNode.setValue(double)
public abstract void labelResult(FacetResult facetResult) throws IOException
FacetRequest
,
such as FacetRequest.getNumLabel()
.
Usually invoked by FacetsAccumulator.accumulate(ScoredDocIDs)
facetResult
- facet result to be labeled.IOException
- on errorpublic final TaxonomyReader getTaxonomyReader()
public final FacetRequest getFacetRequest()
protected boolean isSelfPartition(int ordinal, FacetArrays facetArrays, int offset)
ordinal
- checked facetfacetArrays
- facet arrays for the certain partitionoffset
- offset in input arrays where partition starts