Class FacetComponent.FacetContext
- java.lang.Object
-
- org.apache.solr.handler.component.FacetComponent.FacetContext
-
- Enclosing class:
- FacetComponent
public static class FacetComponent.FacetContext extends Object
Encapsulates facet ranges and facet queries such that their parameters are parsed and cached for efficient re-use.An instance of this class is initialized and kept in the request context via the static method
initContext(ResponseBuilder)
and can be retrieved viagetFacetContext(SolrQueryRequest)
This class is used exclusively in a single-node context (i.e. non distributed requests or an individual shard request). Also see
FacetComponent.FacetInfo
which is dedicated exclusively for merging responses from multiple shards and plays no role during computation of facet counts in a single node request.This API is experimental and subject to change
- See Also:
FacetComponent.FacetInfo
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description List<FacetComponent.FacetBase>
getAllQueryFacets()
List<RangeFacetRequest>
getAllRangeFacetRequests()
static FacetComponent.FacetContext
getFacetContext(SolrQueryRequest req)
Return theFacetComponent.FacetContext
instance cached in the request context.List<FacetComponent.FacetBase>
getQueryFacetsForTag(String tag)
List<RangeFacetRequest>
getRangeFacetRequestsForTag(String tag)
static void
initContext(ResponseBuilder rb)
Initializes FacetContext using request parameters and saves it in the request context which can be retrieved viagetFacetContext(SolrQueryRequest)
-
-
-
Method Detail
-
initContext
public static void initContext(ResponseBuilder rb)
Initializes FacetContext using request parameters and saves it in the request context which can be retrieved viagetFacetContext(SolrQueryRequest)
- Parameters:
rb
- the ResponseBuilder object from which the request parameters are read and to which the FacetContext object is saved.
-
getFacetContext
public static FacetComponent.FacetContext getFacetContext(SolrQueryRequest req) throws IllegalStateException
Return theFacetComponent.FacetContext
instance cached in the request context.- Parameters:
req
- theSolrQueryRequest
- Returns:
- the cached FacetContext instance
- Throws:
IllegalStateException
- if no cached FacetContext instance is found in the request context
-
getAllRangeFacetRequests
public List<RangeFacetRequest> getAllRangeFacetRequests()
- Returns:
- a
List
ofRangeFacetRequest
objects each representing a facet.range to be computed. Returns an empty list if no facet.range were requested.
-
getAllQueryFacets
public List<FacetComponent.FacetBase> getAllQueryFacets()
- Returns:
- a
List
ofFacetComponent.FacetBase
objects each representing a facet.query to be computed. Returns an empty list of no facet.query were requested.
-
getRangeFacetRequestsForTag
public List<RangeFacetRequest> getRangeFacetRequestsForTag(String tag)
- Parameters:
tag
- a String tag usually specified via local param on a facet.pivot- Returns:
- a list of
RangeFacetRequest
objects which have been tagged with the given tag. Returns an empty list if none found.
-
getQueryFacetsForTag
public List<FacetComponent.FacetBase> getQueryFacetsForTag(String tag)
- Parameters:
tag
- a String tag usually specified via local param on a facet.pivot- Returns:
- a list of
FacetComponent.FacetBase
objects which have been tagged with the given tag. Returns and empty List if none found.
-
-