org.apache.solr.request

## Class SimpleFacets

- java.lang.Object
- - org.apache.solr.request.SimpleFacets

- Direct Known Subclasses:
    PivotFacetProcessor, RangeFacetProcessor

      public class SimpleFacets
      extends Object

  A class that generates simple Facet information for a request. More advanced facet implementations may compose or subclass this class to leverage any of its functionality.

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `static class` | `SimpleFacets.CountPair<K extends Comparable<? super K>,V extends Comparable<? super V>>` A simple key=>val pair whose natural order is such that higher vals come before lower vals.
    `protected static class` | `SimpleFacets.ParsedParams`

  - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected DocSet` | `docsOrig` The main set of documents all facet counts should be relative to
    `protected FacetDebugInfo` | `fdebug`
    `protected FacetDebugInfo` | `fdebugParent`
    `protected SolrParams` | `global` Configuration params behavior should be driven by
    `protected ResponseBuilder` | `rb`
    `protected SolrQueryRequest` | `req`
    `protected SolrIndexSearcher` | `searcher` Searcher to use for all calculations

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `SimpleFacets(SolrQueryRequest req, DocSet docs, SolrParams params)`
    `SimpleFacets(SolrQueryRequest req, DocSet docs, SolrParams params, ResponseBuilder rb)`

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `static void` | `checkMincountOnExists(String fieldName, int mincount)`
    `protected DocSet` | `computeDocSet(DocSet baseDocSet, List<String> excludeTagList)`
    `static boolean` | `contains(String ref, String substring, boolean ignoreCase)` Returns `true` if a String contains the given substring.
    `DocSet` | `getDocsOrig()`
    `NamedList<Object>` | `getFacetFieldCounts()` Returns a list of value constraints and the associated facet counts for each facet field specified in the params.
    `NamedList<Object>` | `getFacetIntervalCounts()` Returns a `NamedList` with each entry having the "key" of the interval as name and the count of docs in that interval as value.
    `void` | `getFacetQueryCount(SimpleFacets.ParsedParams parsed, NamedList<Integer> res)`
    `NamedList<Integer>` | `getFacetQueryCounts()` Returns a list of facet counts for each of the facet queries specified in the params
    `NamedList<Integer>` | `getFacetTermEnumCounts(SolrIndexSearcher searcher, DocSet docs, String field, int offset, int limit, int mincount, boolean missing, String sort, String prefix, String contains, boolean ignoreCase, boolean intersectsCheck)` Returns a list of terms in the specified field along with the corresponding count of documents in the set that match that constraint.
    `static int` | `getFieldMissingCount(SolrIndexSearcher searcher, DocSet docs, String fieldName)` Returns a count of the documents in the set which do not have any terms for for the specified field.
    `SolrParams` | `getGlobalParams()`
    `NamedList<Integer>` | `getGroupedCounts(SolrIndexSearcher searcher, DocSet base, String field, boolean multiToken, int offset, int limit, int mincount, boolean missing, String sort, String prefix, String contains, boolean ignoreCase)`
    `int` | `getGroupedFacetQueryCount(Query facetQuery, DocSet docSet)` Returns a grouped facet count for the facet query
    `NamedList` | `getHeatmapCounts()`
    `protected NamedList<Integer>` | `getListedTermCounts(String field, SimpleFacets.ParsedParams parsed, List<String> terms)` Computes the term->count counts for the specified term values relative to the
    `SolrQueryRequest` | `getRequest()`
    `ResponseBuilder` | `getResponseBuilder()`
    `NamedList<Integer>` | `getTermCounts(String field, SimpleFacets.ParsedParams parsed)` Term counts for use in field faceting that resepects the appropriate mincount
    `NamedList<Integer>` | `getTermCountsForPivots(String field, SimpleFacets.ParsedParams parsed)` Term counts for use in pivot faceting that resepcts the appropriate mincount
    `protected SimpleFacets.ParsedParams` | `parseParams(String type, String param)`
    `void` | `setFacetDebugInfo(FacetDebugInfo fdebugParent)`

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

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

- - ### Field Detail

    - #### docsOrig

          protected DocSet docsOrig

      The main set of documents all facet counts should be relative to

    - #### global

          protected final SolrParams global

      Configuration params behavior should be driven by

    - #### searcher

          protected final SolrIndexSearcher searcher

      Searcher to use for all calculations

    - #### req

          protected final SolrQueryRequest req

    - #### rb

          protected final ResponseBuilder rb

    - #### fdebugParent

          protected FacetDebugInfo fdebugParent

    - #### fdebug

          protected FacetDebugInfo fdebug

  - ### Constructor Detail

    - #### SimpleFacets

          public SimpleFacets(SolrQueryRequest req,
                              DocSet docs,
                              SolrParams params)

    - #### SimpleFacets

          public SimpleFacets(SolrQueryRequest req,
                              DocSet docs,
                              SolrParams params,
                              ResponseBuilder rb)

  - ### Method Detail

    - #### setFacetDebugInfo

          public void setFacetDebugInfo(FacetDebugInfo fdebugParent)

    - #### contains

          public static boolean contains(String ref,
                                         String substring,
                                         boolean ignoreCase)

      Returns `true` if a String contains the given substring. Otherwise `false`.
      Parameters:
        `ref` - the `String` to test
        `substring` - the substring to look for
        `ignoreCase` - whether the comparison should be case-insensitive
      Returns:
        Returns `true` iff the String contains the given substring. Otherwise `false`.

    - #### parseParams

          protected SimpleFacets.ParsedParams parseParams(String type,
                                                          String param)
                                                   throws SyntaxError,
                                                          IOException

      Throws:
        `SyntaxError`
        `IOException`

    - #### computeDocSet

          protected DocSet computeDocSet(DocSet baseDocSet,
                                         List<String> excludeTagList)
                                  throws SyntaxError,
                                         IOException

      Throws:
        `SyntaxError`
        `IOException`

    - #### getFacetQueryCounts

          public NamedList<Integer> getFacetQueryCounts()
                                                 throws IOException,
                                                        SyntaxError

      Returns a list of facet counts for each of the facet queries specified in the params
      Throws:
        `IOException`
        `SyntaxError`
      See Also:
        `FacetParams.FACET_QUERY`

    - #### getFacetQueryCount

          public void getFacetQueryCount(SimpleFacets.ParsedParams parsed,
                                         NamedList<Integer> res)
                                  throws SyntaxError,
                                         IOException

      Throws:
        `SyntaxError`
        `IOException`

    - #### getGroupedFacetQueryCount

          public int getGroupedFacetQueryCount(Query facetQuery,
                                               DocSet docSet)
                                        throws IOException

      Returns a grouped facet count for the facet query
      Throws:
        `IOException`
      See Also:
        `FacetParams.FACET_QUERY`

    - #### getTermCountsForPivots

          public NamedList<Integer> getTermCountsForPivots(String field,
                                                           SimpleFacets.ParsedParams parsed)
                                                    throws IOException

      Term counts for use in pivot faceting that resepcts the appropriate mincount
      Throws:
        `IOException`
      See Also:
        `FacetParams.FACET_PIVOT_MINCOUNT`

    - #### getTermCounts

          public NamedList<Integer> getTermCounts(String field,
                                                  SimpleFacets.ParsedParams parsed)
                                           throws IOException

      Term counts for use in field faceting that resepects the appropriate mincount
      Throws:
        `IOException`
      See Also:
        `FacetParams.FACET_MINCOUNT`

    - #### getGroupedCounts

          public NamedList<Integer> getGroupedCounts(SolrIndexSearcher searcher,
                                                     DocSet base,
                                                     String field,
                                                     boolean multiToken,
                                                     int offset,
                                                     int limit,
                                                     int mincount,
                                                     boolean missing,
                                                     String sort,
                                                     String prefix,
                                                     String contains,
                                                     boolean ignoreCase)
                                              throws IOException

      Throws:
        `IOException`

    - #### getFacetFieldCounts

          public NamedList<Object> getFacetFieldCounts()
                                                throws IOException,
                                                       SyntaxError

      Returns a list of value constraints and the associated facet counts for each facet field specified in the params.
      Throws:
        `IOException`
        `SyntaxError`
      See Also:
        `FacetParams.FACET_FIELD`, `getFieldMissingCount(org.apache.solr.search.SolrIndexSearcher, org.apache.solr.search.DocSet, java.lang.String)`, `getFacetTermEnumCounts(org.apache.solr.search.SolrIndexSearcher, org.apache.solr.search.DocSet, java.lang.String, int, int, int, boolean, java.lang.String, java.lang.String, java.lang.String, boolean, boolean)`

    - #### getListedTermCounts

          protected NamedList<Integer> getListedTermCounts(String field,
                                                           SimpleFacets.ParsedParams parsed,
                                                           List<String> terms)
                                                    throws IOException

      Computes the term->count counts for the specified term values relative to the
      Parameters:
        `field` - the name of the field to compute term counts against
        `parsed` - contains the docset to compute term counts relative to
        `terms` - a list of term values (in the specified field) to compute the counts for
      Throws:
        `IOException`

    - #### getFieldMissingCount

          public static int getFieldMissingCount(SolrIndexSearcher searcher,
                                                 DocSet docs,
                                                 String fieldName)
                                          throws IOException

      Returns a count of the documents in the set which do not have any terms for for the specified field.
      Throws:
        `IOException`
      See Also:
        `FacetParams.FACET_MISSING`

    - #### getFacetTermEnumCounts

          public NamedList<Integer> getFacetTermEnumCounts(SolrIndexSearcher searcher,
                                                           DocSet docs,
                                                           String field,
                                                           int offset,
                                                           int limit,
                                                           int mincount,
                                                           boolean missing,
                                                           String sort,
                                                           String prefix,
                                                           String contains,
                                                           boolean ignoreCase,
                                                           boolean intersectsCheck)
                                                    throws IOException

      Returns a list of terms in the specified field along with the corresponding count of documents in the set that match that constraint. This method uses the FilterCache to get the intersection count between `docs` and the DocSet for each term in the filter.
      Throws:
        `IOException`
      See Also:
        `FacetParams.FACET_LIMIT`, `FacetParams.FACET_ZEROS`, `FacetParams.FACET_MISSING`

    - #### checkMincountOnExists

          public static void checkMincountOnExists(String fieldName,
                                                   int mincount)

    - #### getFacetIntervalCounts

          public NamedList<Object> getFacetIntervalCounts()
                                                   throws IOException,
                                                          SyntaxError

      Returns a `NamedList` with each entry having the "key" of the interval as name and the count of docs in that interval as value. All intervals added in the request are included in the returned `NamedList` (included those with 0 count), and it's required that the order of the intervals is deterministic and equals in all shards of a distributed request, otherwise the collation of results will fail.
      Throws:
        `IOException`
        `SyntaxError`

    - #### getHeatmapCounts

          public NamedList getHeatmapCounts()
                                     throws IOException,
                                            SyntaxError

      Throws:
        `IOException`
        `SyntaxError`

    - #### getGlobalParams

          public SolrParams getGlobalParams()

    - #### getDocsOrig

          public DocSet getDocsOrig()

    - #### getRequest

          public SolrQueryRequest getRequest()

    - #### getResponseBuilder

          public ResponseBuilder getResponseBuilder()

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