Search in sources :

Example 6 with DrillSideways

use of org.apache.lucene.facet.DrillSideways 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

DrillDownQuery (org.apache.lucene.facet.DrillDownQuery)6 DrillSideways (org.apache.lucene.facet.DrillSideways)6 DrillSidewaysResult (org.apache.lucene.facet.DrillSideways.DrillSidewaysResult)4 FacetsCollector (org.apache.lucene.facet.FacetsCollector)4 IndexSearcher (org.apache.lucene.search.IndexSearcher)4 Facets (org.apache.lucene.facet.Facets)3 TaxonomyReader (org.apache.lucene.facet.taxonomy.TaxonomyReader)3 DirectoryTaxonomyReader (org.apache.lucene.facet.taxonomy.directory.DirectoryTaxonomyReader)3 Document (org.apache.lucene.document.Document)2 FacetResult (org.apache.lucene.facet.FacetResult)2 FacetsConfig (org.apache.lucene.facet.FacetsConfig)2 MultiFacets (org.apache.lucene.facet.MultiFacets)2 DirectoryReader (org.apache.lucene.index.DirectoryReader)2 IndexReader (org.apache.lucene.index.IndexReader)2 RandomIndexWriter (org.apache.lucene.index.RandomIndexWriter)2 DoubleValuesSource (org.apache.lucene.search.DoubleValuesSource)2 Directory (org.apache.lucene.store.Directory)2 IOException (java.io.IOException)1 HashMap (java.util.HashMap)1 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)1