public class IntervalFacets extends Object implements Iterable<org.apache.solr.request.IntervalFacets.FacetInterval>
facet.query=field:[A TO B]
should be the same as the count of
f.field.facet.interval.set=[A,B]
, however, this method will usually
be faster in cases where there are a larger number of intervals per field.
To use this class, create an instance using
IntervalFacets(SchemaField, SolrIndexSearcher, DocSet, String[], SolrParams)
and then iterate the IntervalFacets.FacetInterval
using iterator()
Intervals Format
Intervals must begin with either '(' or '[', be followed by the start value,
then a comma ',', the end value, and finally ')' or ']'. For example:
The interval limits may be strings, there is no need to add quotes, all the text until the comma will be treated as the start limit, and the text after that will be the end limit, for example: [Buenos Aires,New York]. Keep in mind that a string-like comparison will be done to match documents in string intervals (case-sensitive). The comparator can't be changed. Commas, brackets and square brackets can be escaped by using '\' in front of them. Whitespaces before and after the values will be omitted. Start limit can't be grater than the end limit. Equal limits are allowed.
As with facet.query, the key used to display the result can be set by using local params syntax, for example:
{!key='First Half'}[0,5)
IntervalFacets intervalFacets = new IntervalFacets(schemaField, searcher, docs, intervalStrs, params); for (FacetInterval interval : intervalFacets) { results.add(interval.getKey(), interval.getCount()); }
Constructor and Description |
---|
IntervalFacets(SchemaField schemaField,
SolrIndexSearcher searcher,
DocSet docs,
String[] intervals,
SolrParams params) |
public IntervalFacets(SchemaField schemaField, SolrIndexSearcher searcher, DocSet docs, String[] intervals, SolrParams params) throws SyntaxError, IOException
SyntaxError
IOException
Copyright © 2000-2014 Apache Software Foundation. All Rights Reserved.