org.apache.lucene.facet.search
Class FacetRequest

java.lang.Object
  extended by org.apache.lucene.facet.search.FacetRequest
Direct Known Subclasses:
CountFacetRequest, RangeFacetRequest, Sampler.OverSampledFacetRequest, SumFloatAssociationFacetRequest, SumIntAssociationFacetRequest, SumScoreFacetRequest

public abstract class FacetRequest
extends Object

Defines an aggregation request for a category. Allows specifying the number of child categories to return as well as which categories to consider the "top" (highest or lowest ranking ones).

If the category being aggregated is hierarchical, you can also specify the depth up which to aggregate child categories as well as how the result should be constructed.

WARNING: This API is experimental and might change in incompatible ways in the next release.

Nested Class Summary
static class FacetRequest.ResultMode
          When getDepth() is greater than 1, defines the structure of the result as well as how constraints such as numResults and getNumLabel() are applied.
static class FacetRequest.SortOrder
          Defines which categories to return.
 
Field Summary
 CategoryPath categoryPath
          The category being aggregated in this facet request.
 int numResults
          The number of child categories to return for categoryPath.
 
Constructor Summary
FacetRequest(CategoryPath path, int numResults)
          Constructor with the given category to aggregate and the number of child categories to return.
 
Method Summary
abstract  FacetsAggregator createFacetsAggregator(FacetIndexingParams fip)
          Returns the FacetsAggregator which can aggregate the categories of this facet request.
 boolean equals(Object o)
           
 int getDepth()
          How deeply to look under categoryPath.
 int getNumLabel()
          Allows to specify the number of categories to label.
 FacetRequest.ResultMode getResultMode()
          Return the requested result mode (defaults to FacetRequest.ResultMode.PER_NODE_IN_TREE.
 FacetRequest.SortOrder getSortOrder()
          Return the requested order of results (defaults to FacetRequest.SortOrder.DESCENDING.
 int hashCode()
           
 void setDepth(int depth)
          Sets the depth up to which to aggregate facets.
 void setNumLabel(int numLabel)
          Sets the number of categories to label.
 void setResultMode(FacetRequest.ResultMode resultMode)
          Sets the FacetRequest.ResultMode for this request.
 void setSortOrder(FacetRequest.SortOrder sortOrder)
          Sets the FacetRequest.SortOrder for this request.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

categoryPath

public final CategoryPath categoryPath
The category being aggregated in this facet request.


numResults

public final int numResults
The number of child categories to return for categoryPath.

Constructor Detail

FacetRequest

public FacetRequest(CategoryPath path,
                    int numResults)
Constructor with the given category to aggregate and the number of child categories to return.

Parameters:
path - the category to aggregate. Cannot be null.
numResults - the number of child categories to return. If set to Integer.MAX_VALUE, all immediate child categories will be returned. Must be greater than 0.
Method Detail

createFacetsAggregator

public abstract FacetsAggregator createFacetsAggregator(FacetIndexingParams fip)
Returns the FacetsAggregator which can aggregate the categories of this facet request. The aggregator is expected to aggregate category values into FacetArrays. If the facet request does not support that, e.g. RangeFacetRequest, it can return null. Note though that such requests require a dedicated FacetsAccumulator.


equals

public boolean equals(Object o)
Overrides:
equals in class Object

getDepth

public final int getDepth()
How deeply to look under categoryPath. By default, only its immediate children are aggregated (depth=1). If set to Integer.MAX_VALUE, the entire sub-tree of the category will be aggregated.

NOTE: setting depth to 0 means that only the category itself should be aggregated. In that case, make sure to index the category with CategoryListParams.OrdinalPolicy.ALL_PARENTS, unless it is not the root category (the dimension), in which case CategoryListParams.OrdinalPolicy.ALL_BUT_DIMENSION is fine too.


getNumLabel

public final int getNumLabel()
Allows to specify the number of categories to label. By default all returned categories are labeled.

This allows an app to request a large number of results to return, while labeling them on-demand (e.g. when the UI requests to show more categories).


getResultMode

public final FacetRequest.ResultMode getResultMode()
Return the requested result mode (defaults to FacetRequest.ResultMode.PER_NODE_IN_TREE.


getSortOrder

public final FacetRequest.SortOrder getSortOrder()
Return the requested order of results (defaults to FacetRequest.SortOrder.DESCENDING.


hashCode

public int hashCode()
Overrides:
hashCode in class Object

setDepth

public void setDepth(int depth)
Sets the depth up to which to aggregate facets.

See Also:
getDepth()

setNumLabel

public void setNumLabel(int numLabel)
Sets the number of categories to label.

See Also:
getNumLabel()

setResultMode

public void setResultMode(FacetRequest.ResultMode resultMode)
Sets the FacetRequest.ResultMode for this request.

See Also:
getResultMode()

setSortOrder

public void setSortOrder(FacetRequest.SortOrder sortOrder)
Sets the FacetRequest.SortOrder for this request.

See Also:
getSortOrder()

toString

public String toString()
Overrides:
toString in class Object


Copyright © 2000-2013 Apache Software Foundation. All Rights Reserved.