Package 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 Description static classSimpleFacets.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 classSimpleFacets.ParsedParams
-
Field Summary
Fields Modifier and Type Field Description protected DocSetdocsOrigThe main set of documents all facet counts should be relative toprotected FacetDebugInfofdebugprotected FacetDebugInfofdebugParentprotected org.apache.solr.common.params.SolrParamsglobalConfiguration params behavior should be driven byprotected ResponseBuilderrbprotected SolrQueryRequestreqprotected SolrIndexSearchersearcherSearcher to use for all calculations
-
Constructor Summary
Constructors Constructor Description SimpleFacets(SolrQueryRequest req, DocSet docs, org.apache.solr.common.params.SolrParams params)SimpleFacets(SolrQueryRequest req, DocSet docs, org.apache.solr.common.params.SolrParams params, ResponseBuilder rb)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static voidcheckMincountOnExists(String fieldName, int mincount)protected DocSetcomputeDocSet(DocSet baseDocSet, List<String> excludeTagList)DocSetgetDocsOrig()org.apache.solr.common.util.NamedList<Object>getFacetFieldCounts()Returns a list of value constraints and the associated facet counts for each facet field specified in the params.org.apache.solr.common.util.NamedList<Object>getFacetIntervalCounts()Returns aNamedListwith each entry having the "key" of the interval as name and the count of docs in that interval as value.voidgetFacetQueryCount(SimpleFacets.ParsedParams parsed, org.apache.solr.common.util.NamedList<Integer> res)org.apache.solr.common.util.NamedList<Integer>getFacetQueryCounts()Returns a list of facet counts for each of the facet queries specified in the paramsorg.apache.solr.common.util.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)Works likegetFacetTermEnumCounts(SolrIndexSearcher, DocSet, String, int, int, int, boolean, String, String, Predicate, boolean)but takes a substring directly for the contains check rather than aPredicateinstance.org.apache.solr.common.util.NamedList<Integer>getFacetTermEnumCounts(SolrIndexSearcher searcher, DocSet docs, String field, int offset, int limit, int mincount, boolean missing, String sort, String prefix, Predicate<org.apache.lucene.util.BytesRef> termFilter, 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 intgetFieldMissingCount(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.org.apache.solr.common.params.SolrParamsgetGlobalParams()org.apache.solr.common.util.NamedList<Integer>getGroupedCounts(SolrIndexSearcher searcher, DocSet base, String field, boolean multiToken, int offset, int limit, int mincount, boolean missing, String sort, String prefix, Predicate<org.apache.lucene.util.BytesRef> termFilter)intgetGroupedFacetQueryCount(org.apache.lucene.search.Query facetQuery, DocSet docSet)Returns a grouped facet count for the facet queryorg.apache.solr.common.util.NamedList<Object>getHeatmapCounts()protected org.apache.solr.common.util.NamedList<Integer>getListedTermCounts(String field, SimpleFacets.ParsedParams parsed, List<String> terms)Computes the term->count counts for the specified term values relative to theSolrQueryRequestgetRequest()ResponseBuildergetResponseBuilder()org.apache.solr.common.util.NamedList<Integer>getTermCounts(String field, SimpleFacets.ParsedParams parsed)Term counts for use in field faceting that resepects the appropriate mincountorg.apache.solr.common.util.NamedList<Integer>getTermCountsForPivots(String field, SimpleFacets.ParsedParams parsed)Term counts for use in pivot faceting that resepcts the appropriate mincountprotected Predicate<org.apache.lucene.util.BytesRef>newBytesRefFilter(String field, org.apache.solr.common.params.SolrParams params)Create a new bytes ref filter for filtering facet terms.protected Predicate<org.apache.lucene.util.BytesRef>newExcludeBytesRefFilter(String field, org.apache.solr.common.params.SolrParams params)Create a new bytes ref filter for excluding facet terms.protected SimpleFacets.ParsedParamsparseParams(String type, String param)voidsetFacetDebugInfo(FacetDebugInfo fdebugParent)
-
-
-
Field Detail
-
docsOrig
protected DocSet docsOrig
The main set of documents all facet counts should be relative to
-
global
protected final org.apache.solr.common.params.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, org.apache.solr.common.params.SolrParams params)
-
SimpleFacets
public SimpleFacets(SolrQueryRequest req, DocSet docs, org.apache.solr.common.params.SolrParams params, ResponseBuilder rb)
-
-
Method Detail
-
setFacetDebugInfo
public void setFacetDebugInfo(FacetDebugInfo fdebugParent)
-
parseParams
protected SimpleFacets.ParsedParams parseParams(String type, String param) throws SyntaxError, IOException
- Throws:
SyntaxErrorIOException
-
computeDocSet
protected DocSet computeDocSet(DocSet baseDocSet, List<String> excludeTagList) throws SyntaxError, IOException
- Throws:
SyntaxErrorIOException
-
getFacetQueryCounts
public org.apache.solr.common.util.NamedList<Integer> getFacetQueryCounts() throws IOException, SyntaxError
Returns a list of facet counts for each of the facet queries specified in the params- Throws:
IOExceptionSyntaxError- See Also:
FacetParams.FACET_QUERY
-
getFacetQueryCount
public void getFacetQueryCount(SimpleFacets.ParsedParams parsed, org.apache.solr.common.util.NamedList<Integer> res) throws SyntaxError, IOException
- Throws:
SyntaxErrorIOException
-
getGroupedFacetQueryCount
public int getGroupedFacetQueryCount(org.apache.lucene.search.Query facetQuery, DocSet docSet) throws IOExceptionReturns a grouped facet count for the facet query- Throws:
IOException- See Also:
FacetParams.FACET_QUERY
-
newExcludeBytesRefFilter
protected Predicate<org.apache.lucene.util.BytesRef> newExcludeBytesRefFilter(String field, org.apache.solr.common.params.SolrParams params)
Create a new bytes ref filter for excluding facet terms.This method by default uses the
FacetParams.FACET_EXCLUDETERMSparameter but custom SimpleFacets classes could use a different implementation.- Parameters:
field- the field to check for facet term filtersparams- the request parameter object- Returns:
- A predicate for filtering terms or null if no filters are applicable.
-
newBytesRefFilter
protected Predicate<org.apache.lucene.util.BytesRef> newBytesRefFilter(String field, org.apache.solr.common.params.SolrParams params)
Create a new bytes ref filter for filtering facet terms. If more than one filter is applicable the applicable filters will be returned as anPredicate.and(Predicate)of all such filters.- Parameters:
field- the field to check for facet term filtersparams- the request parameter object- Returns:
- A predicate for filtering terms or null if no filters are applicable.
-
getTermCountsForPivots
public org.apache.solr.common.util.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 org.apache.solr.common.util.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 org.apache.solr.common.util.NamedList<Integer> getGroupedCounts(SolrIndexSearcher searcher, DocSet base, String field, boolean multiToken, int offset, int limit, int mincount, boolean missing, String sort, String prefix, Predicate<org.apache.lucene.util.BytesRef> termFilter) throws IOException
- Throws:
IOException
-
getFacetFieldCounts
public org.apache.solr.common.util.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:
IOExceptionSyntaxError- 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 org.apache.solr.common.util.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 againstparsed- contains the docset to compute term counts relative toterms- 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 org.apache.solr.common.util.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
Works likegetFacetTermEnumCounts(SolrIndexSearcher, DocSet, String, int, int, int, boolean, String, String, Predicate, boolean)but takes a substring directly for the contains check rather than aPredicateinstance.- Throws:
IOException
-
getFacetTermEnumCounts
public org.apache.solr.common.util.NamedList<Integer> getFacetTermEnumCounts(SolrIndexSearcher searcher, DocSet docs, String field, int offset, int limit, int mincount, boolean missing, String sort, String prefix, Predicate<org.apache.lucene.util.BytesRef> termFilter, 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 betweendocsand 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 org.apache.solr.common.util.NamedList<Object> getFacetIntervalCounts() throws IOException, SyntaxError
Returns aNamedListwith 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 returnedNamedList(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:
IOExceptionSyntaxError
-
getHeatmapCounts
public org.apache.solr.common.util.NamedList<Object> getHeatmapCounts() throws IOException, SyntaxError
- Throws:
IOExceptionSyntaxError
-
getGlobalParams
public org.apache.solr.common.params.SolrParams getGlobalParams()
-
getDocsOrig
public DocSet getDocsOrig()
-
getRequest
public SolrQueryRequest getRequest()
-
getResponseBuilder
public ResponseBuilder getResponseBuilder()
-
-