Example usage for org.apache.lucene.facet.range DoubleRange getQuery

List of usage examples for org.apache.lucene.facet.range DoubleRange getQuery

Introduction

In this page you can find the example usage for org.apache.lucene.facet.range DoubleRange getQuery.

Prototype

public Query getQuery(Query fastMatchQuery, DoubleValuesSource valueSource) 

Source Link

Document

Create a Query that matches documents in this range The query will check all documents that match the provided match query, or every document in the index if the match query is null.

Usage

From source file:com.czw.search.lucene.example.facet.DistanceFacetsExample.java

License:Apache License

/** User drills down on the specified range. */
public TopDocs drillDown(DoubleRange range) throws IOException {

    // Passing no baseQuery means we drill down on all
    // documents ("browse only"):
    DrillDownQuery q = new DrillDownQuery(null);
    final DoubleValuesSource vs = getDistanceValueSource();
    q.add("field", range.getQuery(getBoundingBoxQuery(ORIGIN_LATITUDE, ORIGIN_LONGITUDE, range.max), vs));
    DrillSideways ds = new DrillSideways(searcher, config, (TaxonomyReader) null) {
        @Override//from  w ww.j  a  v a2  s .c  om
        protected Facets buildFacetsResult(FacetsCollector drillDowns, FacetsCollector[] drillSideways,
                String[] drillSidewaysDims) throws IOException {
            assert drillSideways.length == 1;
            return new DoubleRangeFacetCounts("field", vs, drillSideways[0], ONE_KM, TWO_KM, FIVE_KM, TEN_KM);
        }
    };
    return ds.search(q, 10).hits;
}