public abstract class FacetRequest extends Object
The facet request additionally defines what information should be computed within the facet results, if and how should results be ordered, etc.
An example facet request is to look at all sub-categories of "Author", and return the 10 with the highest counts (sorted by decreasing count).
Modifier and Type | Class and Description |
---|---|
static class |
FacetRequest.FacetArraysSource
Specifies which array of
FacetArrays should be used to resolve
values. |
static class |
FacetRequest.ResultMode
Result structure manner of applying request's limits such as
getNumLabel() and numResults . |
static class |
FacetRequest.SortOrder
Requested sort order for the results.
|
Modifier and Type | Field and Description |
---|---|
CategoryPath |
categoryPath |
static int |
DEFAULT_DEPTH
Default depth for facets accumulation.
|
static FacetRequest.ResultMode |
DEFAULT_RESULT_MODE
Default result mode
|
int |
numResults |
Constructor and Description |
---|
FacetRequest(CategoryPath path,
int numResults)
Initialize the request with a given path, and a requested number of facets
results.
|
Modifier and Type | Method and Description |
---|---|
Aggregator |
createAggregator(boolean useComplements,
FacetArrays arrays,
TaxonomyReader taxonomy)
Create an aggregator for this facet request.
|
boolean |
equals(Object o) |
int |
getDepth()
How deeply to look under the given category.
|
abstract FacetRequest.FacetArraysSource |
getFacetArraysSource()
|
int |
getNumLabel()
If getNumLabel() < getNumResults(), only the first getNumLabel() results
will have their category paths calculated, and the rest will only be
available as ordinals (category numbers) and will have null paths.
|
FacetRequest.ResultMode |
getResultMode()
Return the requested result mode.
|
FacetRequest.SortOrder |
getSortOrder()
Return the requested order of results.
|
abstract double |
getValueOf(FacetArrays arrays,
int idx)
Return the value of a category used for facets computations for this
request.
|
int |
hashCode() |
void |
setDepth(int depth) |
void |
setNumLabel(int numLabel) |
void |
setResultMode(FacetRequest.ResultMode resultMode) |
void |
setSortOrder(FacetRequest.SortOrder sortOrder) |
String |
toString() |
public static final int DEFAULT_DEPTH
getDepth()
,
Constant Field Valuespublic static final FacetRequest.ResultMode DEFAULT_RESULT_MODE
getResultMode()
public final CategoryPath categoryPath
public final int numResults
public FacetRequest(CategoryPath path, int numResults)
setNumLabel(int)
.
NOTE: if numResults
is given as
Integer.MAX_VALUE
than all the facet results would be
returned, without any limit.
NOTE: it is assumed that the given CategoryPath
is not
modified after construction of this object. Otherwise, some things may not
function properly, e.g. hashCode()
.
IllegalArgumentException
- if numResults is ≤ 0public Aggregator createAggregator(boolean useComplements, FacetArrays arrays, TaxonomyReader taxonomy) throws IOException
useComplements
- whether the complements optimization is being used for current
computation.arrays
- provider for facet arrays in use for current computation.taxonomy
- reader of taxonomy in effect.IOException
- If there is a low-level I/O error.public final int getDepth()
public abstract FacetRequest.FacetArraysSource getFacetArraysSource()
public final int getNumLabel()
If Integer.MAX_VALUE is specified, all results are labled.
The purpose of this parameter is to avoid having to run the whole faceted search again when the user asks for more values for the facet; The application can ask (getNumResults()) for more values than it needs to show, but keep getNumLabel() only the number it wants to immediately show. The slow-down caused by finding more values is negligible, because the slowest part - finding the categories' paths, is avoided.
Depending on the LimitsMode
, this limit is applied
globally or per results node. In the global mode, if this limit is 3, only
3 top results would be labeled. In the per-node mode, if this limit is 3, 3
top children of the target category
would be labeled,
as well as 3 top children of each of them, and so forth, until the depth
defined by getDepth()
.
getResultMode()
public final FacetRequest.ResultMode getResultMode()
public final FacetRequest.SortOrder getSortOrder()
public abstract double getValueOf(FacetArrays arrays, int idx)
arrays
- provider for facet arrays in use for current computation.idx
- an index into the count arrays now in effect in
arrays
. E.g., for ordinal number n, with
partition, of size partitionSize, now covering n,
getValueOf
would be invoked with idx
being n % partitionSize.public void setDepth(int depth)
public void setNumLabel(int numLabel)
public void setResultMode(FacetRequest.ResultMode resultMode)
resultMode
- the resultMode to setgetResultMode()
public void setSortOrder(FacetRequest.SortOrder sortOrder)
Copyright © 2000-2013 Apache Software Foundation. All Rights Reserved.