org.apache.solr.handler.component

## 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 via `getFacetContext(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 and Description
    --- | ---
    `List<FacetComponent.FacetBase>` | `getAllQueryFacets()`
    `List<RangeFacetRequest>` | `getAllRangeFacetRequests()`
    `static FacetComponent.FacetContext` | `getFacetContext(SolrQueryRequest req)` Return the `FacetComponent.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 via `getFacetContext(SolrQueryRequest)`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### 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 via `getFacetContext(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 the `FacetComponent.FacetContext` instance cached in the request context.
      Parameters:
        `req` - the `SolrQueryRequest`
      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` of `RangeFacetRequest` 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` of `FacetComponent.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.

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