Package org.apache.solr.request
Class SimpleFacets
java.lang.Object
org.apache.solr.request.SimpleFacets
- Direct Known Subclasses:
PivotFacetProcessor,RangeFacetProcessor
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 ClassesModifier and TypeClassDescriptionstatic 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 final class -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected DocSetThe main set of documents all facet counts should be relative toprotected FacetDebugInfoprotected FacetDebugInfoprotected final org.apache.solr.common.params.SolrParamsConfiguration params behavior should be driven byprotected final ResponseBuilderprotected final SolrQueryRequestprotected final SolrIndexSearcherSearcher to use for all calculations -
Constructor Summary
ConstructorsConstructorDescriptionSimpleFacets(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
Modifier and TypeMethodDescriptionstatic voidcheckMincountOnExists(String fieldName, int mincount) protected DocSetcomputeDocSet(DocSet baseDocSet, List<String> excludeTagList) org.apache.solr.common.util.SimpleOrderedMap<Object> 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> 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> 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.SolrParamsorg.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> 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 theorg.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 Details
-
docsOrig
The main set of documents all facet counts should be relative to -
global
protected final org.apache.solr.common.params.SolrParams globalConfiguration params behavior should be driven by -
searcher
Searcher to use for all calculations -
req
-
rb
-
fdebugParent
-
fdebug
-
-
Constructor Details
-
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 Details
-
setFacetDebugInfo
-
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, SyntaxErrorReturns a list of facet counts for each of the facet queries specified in the params- Throws:
IOExceptionSyntaxError- See Also:
-
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 IOException Returns a grouped facet count for the facet query- Throws:
IOException- See Also:
-
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:
-
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:
-
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.SimpleOrderedMap<Object> getFacetFieldCounts() throws IOException, SyntaxErrorReturns a list of value constraints and the associated facet counts for each facet field specified in the params.- Throws:
IOExceptionSyntaxError- See Also:
-
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:
-
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:
-
checkMincountOnExists
-
getFacetIntervalCounts
public org.apache.solr.common.util.NamedList<Object> getFacetIntervalCounts() throws IOException, SyntaxErrorReturns 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
-
getRequest
-
getResponseBuilder
-