Search in sources :

Example 16 with DrillDownQuery

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

the class AssociationsFacetsExample method drillDown.

/** User drills down on 'tags/solr'. */
private FacetResult drillDown() throws IOException {
    DirectoryReader indexReader = DirectoryReader.open(indexDir);
    IndexSearcher searcher = new IndexSearcher(indexReader);
    TaxonomyReader taxoReader = new DirectoryTaxonomyReader(taxoDir);
    // Passing no baseQuery means we drill down on all
    // documents ("browse only"):
    DrillDownQuery q = new DrillDownQuery(config);
    // Now user drills down on Publish Date/2010:
    q.add("tags", "solr");
    FacetsCollector fc = new FacetsCollector();
    FacetsCollector.search(searcher, q, 10, fc);
    // Retrieve results
    Facets facets = new TaxonomyFacetSumFloatAssociations("$genre", taxoReader, config, fc);
    FacetResult result = facets.getTopChildren(10, "genre");
    indexReader.close();
    taxoReader.close();
    return result;
}
Also used : IndexSearcher(org.apache.lucene.search.IndexSearcher) Facets(org.apache.lucene.facet.Facets) DirectoryReader(org.apache.lucene.index.DirectoryReader) TaxonomyReader(org.apache.lucene.facet.taxonomy.TaxonomyReader) DirectoryTaxonomyReader(org.apache.lucene.facet.taxonomy.directory.DirectoryTaxonomyReader) DrillDownQuery(org.apache.lucene.facet.DrillDownQuery) FacetResult(org.apache.lucene.facet.FacetResult) TaxonomyFacetSumFloatAssociations(org.apache.lucene.facet.taxonomy.TaxonomyFacetSumFloatAssociations) DirectoryTaxonomyReader(org.apache.lucene.facet.taxonomy.directory.DirectoryTaxonomyReader) FacetsCollector(org.apache.lucene.facet.FacetsCollector)

Example 17 with DrillDownQuery

use of org.apache.lucene.facet.DrillDownQuery 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)17 IndexSearcher (org.apache.lucene.search.IndexSearcher)14 Facets (org.apache.lucene.facet.Facets)12 FacetsCollector (org.apache.lucene.facet.FacetsCollector)12 FacetResult (org.apache.lucene.facet.FacetResult)8 Document (org.apache.lucene.document.Document)7 FacetsConfig (org.apache.lucene.facet.FacetsConfig)7 TaxonomyReader (org.apache.lucene.facet.taxonomy.TaxonomyReader)7 DirectoryTaxonomyReader (org.apache.lucene.facet.taxonomy.directory.DirectoryTaxonomyReader)7 DirectoryReader (org.apache.lucene.index.DirectoryReader)7 Directory (org.apache.lucene.store.Directory)7 DrillSideways (org.apache.lucene.facet.DrillSideways)6 RandomIndexWriter (org.apache.lucene.index.RandomIndexWriter)6 DrillSidewaysResult (org.apache.lucene.facet.DrillSideways.DrillSidewaysResult)4 MultiFacets (org.apache.lucene.facet.MultiFacets)4 IndexReader (org.apache.lucene.index.IndexReader)4 DoublePoint (org.apache.lucene.document.DoublePoint)3 LongPoint (org.apache.lucene.document.LongPoint)3 FacetField (org.apache.lucene.facet.FacetField)3 DoubleValuesSource (org.apache.lucene.search.DoubleValuesSource)3