org.apache.lucene.facet.range.LongRange Java Examples

The following examples show how to use org.apache.lucene.facet.range.LongRange. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: RangeFacetsExample.java    From lucene-solr with Apache License 2.0 6 votes vote down vote up
/** User drills down on the specified range, and also computes drill sideways counts. */
public DrillSideways.DrillSidewaysResult drillSideways(LongRange range) throws IOException {
  // Passing no baseQuery means we drill down on all
  // documents ("browse only"):
  DrillDownQuery q = new DrillDownQuery(getConfig());
  q.add("timestamp", LongPoint.newRangeQuery("timestamp", range.min, range.max));

  // DrillSideways only handles taxonomy and sorted set drill facets by default; to do range facets we must subclass and override the
  // buildFacetsResult method.
  DrillSideways.DrillSidewaysResult result = new DrillSideways(searcher, getConfig(), null, null) {
    @Override
    protected Facets buildFacetsResult(FacetsCollector drillDowns, FacetsCollector[] drillSideways, String[] drillSidewaysDims) throws IOException {
      // If we had other dims we would also compute their drill-down or drill-sideways facets here:
      assert drillSidewaysDims[0].equals("timestamp");
      return new LongRangeFacetCounts("timestamp", drillSideways[0],
                                      PAST_HOUR,
                                      PAST_SIX_HOURS,
                                      PAST_DAY);
    }
  }.search(q, 10);

  return result;
}
 
Example #2
Source File: RangeFacetsExample.java    From lucene-solr with Apache License 2.0 5 votes vote down vote up
/** User drills down on the specified range. */
public TopDocs drillDown(LongRange range) throws IOException {

  // Passing no baseQuery means we drill down on all
  // documents ("browse only"):
  DrillDownQuery q = new DrillDownQuery(getConfig());

  q.add("timestamp", LongPoint.newRangeQuery("timestamp", range.min, range.max));
  return searcher.search(q, 10);
}