org.apache.solr.request
Class SimpleFacets

java.lang.Object
  extended by org.apache.solr.request.SimpleFacets

public class SimpleFacets
extends java.lang.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 java.lang.Comparable<? super K>,V extends java.lang.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
          The main set of documents all facet counts should be relative to
protected  SolrParams params
          Configuration params behavior should be driven by
protected  SolrIndexSearcher searcher
          Searcher to use for all calculations
 
Constructor Summary
SimpleFacets(SolrIndexSearcher searcher, DocSet docs, SolrParams params)
           
 
Method Summary
 NamedList getFacetCounts()
          Looks at various Params to determing if any simple Facet Constraint count computations are desired.
 NamedList getFacetFieldCounts()
          Returns a list of value constraints and the associated facet counts for each facet field specified in the params.
 NamedList getFacetQueryCounts()
          Returns a list of facet counts for each of the facet queries specified in the params
 NamedList getFacetTermEnumCounts(SolrIndexSearcher searcher, DocSet docs, java.lang.String field, int offset, int limit, int mincount, boolean missing, boolean sort, java.lang.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 getFieldCacheCounts(SolrIndexSearcher searcher, DocSet docs, java.lang.String fieldName, int offset, int limit, int mincount, boolean missing, boolean sort, java.lang.String prefix)
          Use the Lucene FieldCache to get counts for each unique field value in docs.
static int getFieldMissingCount(SolrIndexSearcher searcher, DocSet docs, java.lang.String fieldName)
          Returns a count of the documents in the set which do not have any terms for for the specified field.
 NamedList getTermCounts(java.lang.String field)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

docs

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


params

protected SolrParams params
Configuration params behavior should be driven by


searcher

protected SolrIndexSearcher searcher
Searcher to use for all calculations

Constructor Detail

SimpleFacets

public SimpleFacets(SolrIndexSearcher searcher,
                    DocSet docs,
                    SolrParams params)
Method Detail

getFacetCounts

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

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

getFacetQueryCounts

public NamedList getFacetQueryCounts()
                              throws java.io.IOException,
                                     org.apache.lucene.queryParser.ParseException
Returns a list of facet counts for each of the facet queries specified in the params

Throws:
java.io.IOException
org.apache.lucene.queryParser.ParseException
See Also:
SolrParams.FACET_QUERY

getTermCounts

public NamedList getTermCounts(java.lang.String field)
                        throws java.io.IOException
Throws:
java.io.IOException

getFacetFieldCounts

public NamedList getFacetFieldCounts()
                              throws java.io.IOException
Returns a list of value constraints and the associated facet counts for each facet field specified in the params.

Throws:
java.io.IOException
See Also:
SolrParams.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, boolean, java.lang.String)

getFieldMissingCount

public static int getFieldMissingCount(SolrIndexSearcher searcher,
                                       DocSet docs,
                                       java.lang.String fieldName)
                                throws java.io.IOException
Returns a count of the documents in the set which do not have any terms for for the specified field.

Throws:
java.io.IOException
See Also:
SolrParams.FACET_MISSING

getFieldCacheCounts

public static NamedList getFieldCacheCounts(SolrIndexSearcher searcher,
                                            DocSet docs,
                                            java.lang.String fieldName,
                                            int offset,
                                            int limit,
                                            int mincount,
                                            boolean missing,
                                            boolean sort,
                                            java.lang.String prefix)
                                     throws java.io.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:
java.io.IOException

getFacetTermEnumCounts

public NamedList getFacetTermEnumCounts(SolrIndexSearcher searcher,
                                        DocSet docs,
                                        java.lang.String field,
                                        int offset,
                                        int limit,
                                        int mincount,
                                        boolean missing,
                                        boolean sort,
                                        java.lang.String prefix)
                                 throws java.io.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:
java.io.IOException
See Also:
SolrParams.FACET_LIMIT, SolrParams.FACET_ZEROS, SolrParams.FACET_MISSING


Copyright © 2006 - 2008 The Apache Software Foundation