Search in sources :

Example 1 with DoubleRangeFacetCounts

use of org.apache.lucene.facet.range.DoubleRangeFacetCounts in project lucene-solr by apache.

the class DistanceFacetsExample method search.

/** User runs a query and counts facets. */
public FacetResult search() throws IOException {
    FacetsCollector fc = new FacetsCollector();
    searcher.search(new MatchAllDocsQuery(), fc);
    Facets facets = new DoubleRangeFacetCounts("field", getDistanceValueSource(), fc, getBoundingBoxQuery(ORIGIN_LATITUDE, ORIGIN_LONGITUDE, 10.0), ONE_KM, TWO_KM, FIVE_KM, TEN_KM);
    return facets.getTopChildren(10, "field");
}
Also used : Facets(org.apache.lucene.facet.Facets) DoubleRangeFacetCounts(org.apache.lucene.facet.range.DoubleRangeFacetCounts) MatchAllDocsQuery(org.apache.lucene.search.MatchAllDocsQuery) FacetsCollector(org.apache.lucene.facet.FacetsCollector)

Example 2 with DoubleRangeFacetCounts

use of org.apache.lucene.facet.range.DoubleRangeFacetCounts in project lucene-solr by apache.

the class DistanceFacetsExample method drillDown.

/** 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
        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;
}
Also used : DrillDownQuery(org.apache.lucene.facet.DrillDownQuery) DrillSideways(org.apache.lucene.facet.DrillSideways) DoubleRangeFacetCounts(org.apache.lucene.facet.range.DoubleRangeFacetCounts) DoubleValuesSource(org.apache.lucene.search.DoubleValuesSource) FacetsCollector(org.apache.lucene.facet.FacetsCollector)

Aggregations

FacetsCollector (org.apache.lucene.facet.FacetsCollector)2 DoubleRangeFacetCounts (org.apache.lucene.facet.range.DoubleRangeFacetCounts)2 DrillDownQuery (org.apache.lucene.facet.DrillDownQuery)1 DrillSideways (org.apache.lucene.facet.DrillSideways)1 Facets (org.apache.lucene.facet.Facets)1 DoubleValuesSource (org.apache.lucene.search.DoubleValuesSource)1 MatchAllDocsQuery (org.apache.lucene.search.MatchAllDocsQuery)1