Examples of FacetsCollector


Examples of org.apache.lucene.facet.search.FacetsCollector

    ArrayList<FacetRequest> requests = new ArrayList<FacetRequest>(expectedCounts.size());
    for (String dim : expectedCounts.keySet()) {
      requests.add(new CountFacetRequest(new CategoryPath(dim), 5));
    }
    FacetSearchParams fsp = new FacetSearchParams(fip, requests);
    FacetsCollector fc = FacetsCollector.create(fsp, indexReader, taxoReader);
    MatchAllDocsQuery base = new MatchAllDocsQuery();
    searcher.search(base, fc);
    List<FacetResult> facetResults = fc.getFacetResults();
    assertEquals(requests.size(), facetResults.size());
    for (FacetResult res : facetResults) {
      FacetResultNode node = res.getFacetResultNode();
      String dim = node.label.components[0];
      assertEquals("wrong count for " + dim, expectedCounts.get(dim).intValue(), (int) node.value);
View Full Code Here

Examples of org.apache.lucene.facet.search.FacetsCollector

      CategoryPath drillDownCP = new CategoryPath(dim);
      FacetSearchParams fsp = new FacetSearchParams(fip, new CountFacetRequest(drillDownCP, 10));
      DrillDownQuery drillDown = new DrillDownQuery(fip, new MatchAllDocsQuery());
      drillDown.add(drillDownCP);
      TotalHitCountCollector total = new TotalHitCountCollector();
      FacetsCollector fc = FacetsCollector.create(fsp, indexReader, taxoReader);
      searcher.search(drillDown, MultiCollector.wrap(fc, total));
      assertTrue("no results for drill-down query " + drillDown, total.getTotalHits() > 0);
      List<FacetResult> facetResults = fc.getFacetResults();
      assertEquals(1, facetResults.size());
      FacetResultNode rootNode = facetResults.get(0).getFacetResultNode();
      assertEquals("wrong count for " + dim, expectedCounts.get(dim).intValue(), (int) rootNode.value);
    }
  }
View Full Code Here

Examples of org.apache.lucene.facet.search.FacetsCollector

  // than once does not alter the results
  public void testTwoSameRequests() throws Exception {
    final CountFacetRequest facetRequest = new CountFacetRequest(new CategoryPath("root"), 10);
    FacetSearchParams fsp = new FacetSearchParams(fip, facetRequest);
   
    FacetsCollector fc = FacetsCollector.create(fsp, indexReader, taxoReader);
    searcher.search(new MatchAllDocsQuery(), fc);
   
    final String expected = fc.getFacetResults().get(0).toString();

    // now add the same facet request with duplicates (same instance and same one)
    fsp = new FacetSearchParams(fip, facetRequest, facetRequest, new CountFacetRequest(new CategoryPath("root"), 10));

    // make sure the search params holds 3 requests now
    assertEquals(3, fsp.facetRequests.size());
   
    fc = FacetsCollector.create(fsp, indexReader, taxoReader);
    searcher.search(new MatchAllDocsQuery(), fc);
    List<FacetResult> actual = fc.getFacetResults();

    // all 3 results should have the same toString()
    assertEquals("same FacetRequest but different result?", expected, actual.get(0).toString());
    assertEquals("same FacetRequest but different result?", expected, actual.get(1).toString());
    assertEquals("same FacetRequest but different result?", expected, actual.get(2).toString());
View Full Code Here

Examples of org.apache.lucene.facet.search.FacetsCollector

    RangeFacetRequest<LongRange> rangeFacetRequest = new RangeFacetRequest<LongRange>("timestamp",
                                     new LongRange("Past hour", nowSec-3600, true, nowSec, true),
                                     new LongRange("Past six hours", nowSec-6*3600, true, nowSec, true),
                                     new LongRange("Past day", nowSec-24*3600, true, nowSec, true));
    // Aggregatses the facet counts
    FacetsCollector fc = FacetsCollector.create(new RangeAccumulator(rangeFacetRequest));

    // MatchAllDocsQuery is for "browsing" (counts facets
    // for all non-deleted docs in the index); normally
    // you'd use a "normal" query, and use MultiCollector to
    // wrap collecting the "normal" hits and also facets:
    searcher.search(new MatchAllDocsQuery(), fc);

    // Retrieve results
    return fc.getFacetResults();
  }
View Full Code Here

Examples of org.apache.lucene.facet.search.FacetsCollector

    FacetSearchParams fsp = new FacetSearchParams(
        new SumValueSourceFacetRequest(new CategoryPath("A"), 10, expr.getValueSource(bindings), true));

    // Aggregates the facet values
    FacetsCollector fc = FacetsCollector.create(fsp, searcher.getIndexReader(), taxoReader);

    // MatchAllDocsQuery is for "browsing" (counts facets
    // for all non-deleted docs in the index); normally
    // you'd use a "normal" query, and use MultiCollector to
    // wrap collecting the "normal" hits and also facets:
    searcher.search(new MatchAllDocsQuery(), fc);

    // Retrieve results
    List<FacetResult> facetResults = fc.getFacetResults();
   
    indexReader.close();
    taxoReader.close();
   
    return facetResults;
View Full Code Here

Examples of org.apache.lucene.facet.search.FacetsCollector

   
    CategoryPath tags = new CategoryPath("tags");
    CategoryPath genre = new CategoryPath("genre");
    FacetSearchParams fsp = new FacetSearchParams(new SumIntAssociationFacetRequest(tags, 10),
        new SumFloatAssociationFacetRequest(genre, 10));
    FacetsCollector fc = FacetsCollector.create(fsp, indexReader, taxoReader);
   
    // MatchAllDocsQuery is for "browsing" (counts facets
    // for all non-deleted docs in the index); normally
    // you'd use a "normal" query, and use MultiCollector to
    // wrap collecting the "normal" hits and also facets:
    searcher.search(new MatchAllDocsQuery(), fc);
   
    // Retrieve results
    List<FacetResult> facetResults = fc.getFacetResults();
   
    indexReader.close();
    taxoReader.close();
   
    return facetResults;
View Full Code Here

Examples of org.apache.lucene.facet.search.FacetsCollector

    FacetSearchParams fsp = new FacetSearchParams(
        new CountFacetRequest(new CategoryPath("Publish Date"), 10),
        new CountFacetRequest(new CategoryPath("Author"), 10));

    // Aggregates the facet counts
    FacetsCollector fc = FacetsCollector.create(fsp, searcher.getIndexReader(), taxoReader);

    // MatchAllDocsQuery is for "browsing" (counts facets
    // for all non-deleted docs in the index); normally
    // you'd use a "normal" query, and use MultiCollector to
    // wrap collecting the "normal" hits and also facets:
    searcher.search(new MatchAllDocsQuery(), fc);

    // Retrieve results
    List<FacetResult> facetResults = fc.getFacetResults();
   
    indexReader.close();
    taxoReader.close();
   
    return facetResults;
View Full Code Here

Examples of org.apache.lucene.facet.search.FacetsCollector

    // Passing no baseQuery means we drill down on all
    // documents ("browse only"):
    DrillDownQuery q = new DrillDownQuery(fsp.indexingParams);
    q.add(new CategoryPath("Publish Date/2010", '/'));
    FacetsCollector fc = FacetsCollector.create(fsp, searcher.getIndexReader(), taxoReader);
    searcher.search(q, fc);

    // Retrieve results
    List<FacetResult> facetResults = fc.getFacetResults();
   
    indexReader.close();
    taxoReader.close();
   
    return facetResults;
View Full Code Here

Examples of org.apache.lucene.facet.search.FacetsCollector

    FacetSearchParams fsp = new FacetSearchParams(indexingParams,
        new CountFacetRequest(new CategoryPath("Publish Date"), 10),
        new CountFacetRequest(new CategoryPath("Author"), 10));

    // Aggregatses the facet counts
    FacetsCollector fc = FacetsCollector.create(fsp, searcher.getIndexReader(), taxoReader);

    // MatchAllDocsQuery is for "browsing" (counts facets
    // for all non-deleted docs in the index); normally
    // you'd use a "normal" query, and use MultiCollector to
    // wrap collecting the "normal" hits and also facets:
    searcher.search(new MatchAllDocsQuery(), fc);

    // Retrieve results
    List<FacetResult> facetResults = fc.getFacetResults();
   
    indexReader.close();
    taxoReader.close();
   
    return facetResults;
View Full Code Here

Examples of org.apache.lucene.facet.search.FacetsCollector

    FacetSearchParams fsp = new FacetSearchParams(
        new CountFacetRequest(new CategoryPath("Publish Year"), 10),
        new CountFacetRequest(new CategoryPath("Author"), 10));

    // Aggregatses the facet counts
    FacetsCollector fc = FacetsCollector.create(new SortedSetDocValuesAccumulator(state, fsp));

    // MatchAllDocsQuery is for "browsing" (counts facets
    // for all non-deleted docs in the index); normally
    // you'd use a "normal" query, and use MultiCollector to
    // wrap collecting the "normal" hits and also facets:
    searcher.search(new MatchAllDocsQuery(), fc);

    // Retrieve results
    List<FacetResult> facetResults = fc.getFacetResults();
   
    indexReader.close();
   
    return facetResults;
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.