org.apache.solr.request
Class SimpleFacets

java.lang.Object
  extended by org.apache.solr.request.SimpleFacets
Direct Known Subclasses:
PivotFacetHelper

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 it's functionality.


Nested Class Summary
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.
 
Field Summary
protected  DocSet docs
           
protected  DocSet docsOrig
          The main set of documents all facet counts should be relative to
protected  SimpleOrderedMap<Object> facetResponse
           
protected  String facetValue
           
protected  String key
           
protected  SolrParams localParams
           
protected  SolrParams orig
          Configuration params behavior should be driven by
protected  SolrParams params
           
protected  ResponseBuilder rb
           
protected  SolrQueryRequest req
           
protected  SolrParams required
           
protected  SolrIndexSearcher searcher
          Searcher to use for all calculations
protected  int threads
           
 
Constructor Summary
SimpleFacets(SolrQueryRequest req, DocSet docs, SolrParams params)
           
SimpleFacets(SolrQueryRequest req, DocSet docs, SolrParams params, ResponseBuilder rb)
           
 
Method Summary
 NamedList<Object> getFacetCounts()
          Looks at various Params to determining if any simple Facet Constraint count computations are desired.
 NamedList<Object> getFacetDateCounts()
          Deprecated. Use getFacetRangeCounts which is more generalized
 void getFacetDateCounts(String dateFacet, NamedList<Object> resOuter)
          Deprecated. Use getFacetRangeCounts which is more generalized
 NamedList<Object> getFacetFieldCounts()
          Returns a list of value constraints and the associated facet counts for each facet field specified in the params.
 NamedList<Integer> getFacetQueryCounts()
          Returns a list of facet counts for each of the facet queries specified in the params
 NamedList<Object> getFacetRangeCounts()
          Returns a list of value constraints and the associated facet counts for each facet numerical field, range, and interval specified in the SolrParams
 NamedList<Integer> getFacetTermEnumCounts(SolrIndexSearcher searcher, DocSet docs, String field, int offset, int limit, int mincount, boolean missing, String sort, String prefix)
          Returns a list of terms in the specified field along with the corresponding count of documents in the set that match that constraint.
static NamedList<Integer> getFieldCacheCounts(SolrIndexSearcher searcher, DocSet docs, String fieldName, int offset, int limit, int mincount, boolean missing, String sort, String prefix)
          Use the Lucene FieldCache to get counts for each unique field value in docs.
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.
 NamedList<Integer> getGroupedCounts(SolrIndexSearcher searcher, DocSet base, String field, boolean multiToken, int offset, int limit, int mincount, boolean missing, String sort, String prefix)
           
 int getGroupedFacetQueryCount(Query facetQuery)
          Returns a grouped facet count for the facet query
 NamedList<Integer> getTermCounts(String field)
           
 NamedList<Integer> getTermCounts(String field, DocSet base)
           
protected  void parseParams(String type, String param)
           
protected  int rangeCount(SchemaField sf, Date low, Date high, boolean iLow, boolean iHigh)
          Deprecated. Use rangeCount(SchemaField,String,String,boolean,boolean) which is more generalized
protected  int rangeCount(SchemaField sf, String low, String high, boolean iLow, boolean iHigh)
          Macro for getting the numDocs of range over docs
 
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


orig

protected final SolrParams orig
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

facetResponse

protected SimpleOrderedMap<Object> facetResponse

localParams

protected SolrParams localParams

params

protected SolrParams params

required

protected SolrParams required

facetValue

protected String facetValue

docs

protected DocSet docs

key

protected String key

threads

protected int threads
Constructor Detail

SimpleFacets

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

SimpleFacets

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

parseParams

protected void parseParams(String type,
                           String param)
                    throws SyntaxError,
                           IOException
Throws:
SyntaxError
IOException

getFacetCounts

public NamedList<Object> getFacetCounts()
Looks at various Params to determining if any simple Facet Constraint count computations are desired.

Returns:
a NamedList of Facet Count info or null
See Also:
getFacetQueryCounts(), getFacetFieldCounts(), getFacetDateCounts(), getFacetRangeCounts(), FacetParams.FACET

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

getGroupedFacetQueryCount

public int getGroupedFacetQueryCount(Query facetQuery)
                              throws IOException
Returns a grouped facet count for the facet query

Throws:
IOException
See Also:
FacetParams.FACET_QUERY

getTermCounts

public NamedList<Integer> getTermCounts(String field)
                                 throws IOException
Throws:
IOException

getTermCounts

public NamedList<Integer> getTermCounts(String field,
                                        DocSet base)
                                 throws IOException
Throws:
IOException

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)
                                    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)

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

getFieldCacheCounts

public static NamedList<Integer> getFieldCacheCounts(SolrIndexSearcher searcher,
                                                     DocSet docs,
                                                     String fieldName,
                                                     int offset,
                                                     int limit,
                                                     int mincount,
                                                     boolean missing,
                                                     String sort,
                                                     String prefix)
                                              throws IOException
Use the Lucene FieldCache to get counts for each unique field value in docs. The field must have at most one indexed token per document.

Throws:
IOException

getFacetTermEnumCounts

public NamedList<Integer> getFacetTermEnumCounts(SolrIndexSearcher searcher,
                                                 DocSet docs,
                                                 String field,
                                                 int offset,
                                                 int limit,
                                                 int mincount,
                                                 boolean missing,
                                                 String sort,
                                                 String prefix)
                                          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

getFacetDateCounts

@Deprecated
public NamedList<Object> getFacetDateCounts()
                                     throws IOException,
                                            SyntaxError
Deprecated. Use getFacetRangeCounts which is more generalized

Returns a list of value constraints and the associated facet counts for each facet date field, range, and interval specified in the SolrParams

Throws:
IOException
SyntaxError
See Also:
FacetParams.FACET_DATE

getFacetDateCounts

@Deprecated
public void getFacetDateCounts(String dateFacet,
                                          NamedList<Object> resOuter)
                        throws IOException,
                               SyntaxError
Deprecated. Use getFacetRangeCounts which is more generalized

Throws:
IOException
SyntaxError

getFacetRangeCounts

public NamedList<Object> getFacetRangeCounts()
                                      throws IOException,
                                             SyntaxError
Returns a list of value constraints and the associated facet counts for each facet numerical field, range, and interval specified in the SolrParams

Throws:
IOException
SyntaxError
See Also:
FacetParams.FACET_RANGE

rangeCount

protected int rangeCount(SchemaField sf,
                         String low,
                         String high,
                         boolean iLow,
                         boolean iHigh)
                  throws IOException
Macro for getting the numDocs of range over docs

Throws:
IOException
See Also:
SolrIndexSearcher.numDocs(org.apache.lucene.search.Query, org.apache.solr.search.DocSet), TermRangeQuery

rangeCount

@Deprecated
protected int rangeCount(SchemaField sf,
                                    Date low,
                                    Date high,
                                    boolean iLow,
                                    boolean iHigh)
                  throws IOException
Deprecated. Use rangeCount(SchemaField,String,String,boolean,boolean) which is more generalized

Throws:
IOException


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