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 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 Description protected DocSet
docsOrig
The main set of documents all facet counts should be relative toprotected FacetDebugInfo
fdebug
protected FacetDebugInfo
fdebugParent
protected org.apache.solr.common.params.SolrParams
global
Configuration params behavior should be driven byprotected ResponseBuilder
rb
protected SolrQueryRequest
req
protected SolrIndexSearcher
searcher
Searcher 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 void
checkMincountOnExists(String fieldName, int mincount)
protected DocSet
computeDocSet(DocSet baseDocSet, List<String> excludeTagList)
DocSet
getDocsOrig()
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 aNamedList
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, 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 aPredicate
instance.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 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.org.apache.solr.common.params.SolrParams
getGlobalParams()
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)
int
getGroupedFacetQueryCount(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 theSolrQueryRequest
getRequest()
ResponseBuilder
getResponseBuilder()
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.ParsedParams
parseParams(String type, String param)
void
setFacetDebugInfo(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:
SyntaxError
IOException
-
computeDocSet
protected DocSet computeDocSet(DocSet baseDocSet, List<String> excludeTagList) throws SyntaxError, IOException
- Throws:
SyntaxError
IOException
-
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:
IOException
SyntaxError
- See Also:
FacetParams.FACET_QUERY
-
getFacetQueryCount
public void getFacetQueryCount(SimpleFacets.ParsedParams parsed, org.apache.solr.common.util.NamedList<Integer> res) throws SyntaxError, IOException
- Throws:
SyntaxError
IOException
-
getGroupedFacetQueryCount
public int getGroupedFacetQueryCount(org.apache.lucene.search.Query facetQuery, DocSet docSet) throws IOException
Returns 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_EXCLUDETERMS
parameter 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:
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 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 aPredicate
instance.- 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 betweendocs
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 org.apache.solr.common.util.NamedList<Object> getFacetIntervalCounts() throws IOException, SyntaxError
Returns aNamedList
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 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:
IOException
SyntaxError
-
getHeatmapCounts
public org.apache.solr.common.util.NamedList<Object> getHeatmapCounts() throws IOException, SyntaxError
- Throws:
IOException
SyntaxError
-
getGlobalParams
public org.apache.solr.common.params.SolrParams getGlobalParams()
-
getDocsOrig
public DocSet getDocsOrig()
-
getRequest
public SolrQueryRequest getRequest()
-
getResponseBuilder
public ResponseBuilder getResponseBuilder()
-
-