Package org.apache.lucene.search

Examples of org.apache.lucene.search.MatchAllDocsQuery


    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();
View Full Code Here


      TaxonomyReader taxoReader, IndexSearcher searcher) throws IOException {
    // verify drill-down
    for (String dim : expectedCounts.keySet()) {
      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);
View Full Code Here

    // 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(), c);

    // Retrieve & verify results:
    List<FacetResult> results = c.getFacetResults();
    assertEquals(2, results.size());
    assertEquals("Publish Date (0)\n  2012 (2)\n  2010 (2)\n  1999 (1)\n",
        FacetTestUtils.toSimpleString(results.get(0)));
    assertEquals("Author (0)\n  Lisa (2)\n  Frank (1)\n  Susan (1)\n  Bob (1)\n",
        FacetTestUtils.toSimpleString(results.get(1)));

   
    // Now user drills down on Publish Date/2010:
    fsp = new FacetSearchParams(new CountFacetRequest(new CategoryPath("Author"), 10));
    DrillDownQuery q2 = new DrillDownQuery(fsp.indexingParams, new MatchAllDocsQuery());
    q2.add(new CategoryPath("Publish Date/2010", '/'));
    c = FacetsCollector.create(fsp, searcher.getIndexReader(), taxoReader);
    searcher.search(q2, c);
    results = c.getFacetResults();
    assertEquals(1, results.size());
View Full Code Here

    // 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(), c);
    List<FacetResult> results = c.getFacetResults();
    assertEquals(1, results.size());
    assertEquals(1, (int) results.get(0).getFacetResultNode().value);

    // LUCENE-4913:
View Full Code Here

   
    // 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(), c);
    List<FacetResult> results = c.getFacetResults();
    assertEquals(1, results.size());
    FacetResultNode root = results.get(0).getFacetResultNode();
    assertEquals(numLabels, root.subResults.size());
    Set<String> allLabels = new HashSet<String>();
View Full Code Here

public class TestTopKResultsHandlerRandom extends BaseTestTopK {
 
  private List<FacetResult> countFacets(FacetIndexingParams fip, int numResults, final boolean doComplement)
      throws IOException {
    Query q = new MatchAllDocsQuery();
    FacetSearchParams facetSearchParams = searchParamsWithRequests(numResults, fip);
    OldFacetsAccumulator sfa = new OldFacetsAccumulator(facetSearchParams, indexReader, taxoReader);
    sfa.setComplementThreshold(doComplement ? OldFacetsAccumulator.FORCE_COMPLEMENT : OldFacetsAccumulator.DISABLE_COMPLEMENT);
    FacetsCollector fc = FacetsCollector.create(sfa);
    searcher.search(q, fc);
View Full Code Here

      cps[i] = new CategoryPath[drillDowns[i].length];
      for (int j = 0; j < cps[i].length; j++) {
        cps[i][j] = new CategoryPath(drillDowns[i][j], '/');
      }
    }
    DrillDownQuery ddq = new DrillDownQuery(FacetIndexingParams.DEFAULT, new MatchAllDocsQuery());
    for (CategoryPath[] cats : cps) {
      ddq.add(cats);
    }
   
    List<FacetRequest> facetRequests = new ArrayList<FacetRequest>();
View Full Code Here

  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());
View Full Code Here

          //System.out.println("search maxOrd=" + pair.taxonomyReader.getSize());
          int topN = _TestUtil.nextInt(random(), 1, 20);
          CountFacetRequest cfr = new CountFacetRequest(new CategoryPath("field"), topN);
          FacetSearchParams fsp = new FacetSearchParams(cfr);
          FacetsCollector fc = FacetsCollector.create(fsp, pair.searcher.getIndexReader(), pair.taxonomyReader);
          pair.searcher.search(new MatchAllDocsQuery(), fc);
          List<FacetResult> results = fc.getFacetResults();
          FacetResult fr = results.get(0);
          FacetResultNode root = results.get(0).getFacetResultNode();
          assertTrue(root.ordinal != 0);
View Full Code Here

    IndexSearcher searcher = newSearcher(indexReader);
   
    FacetSearchParams fsp = new FacetSearchParams(new CountFacetRequest(CP_A, NUM_CHILDREN_CP_A),
        new CountFacetRequest(CP_B, NUM_CHILDREN_CP_B));
    FacetsCollector fc = FacetsCollector.create(randomAccumulator(fsp, indexReader, taxoReader));
    searcher.search(new MatchAllDocsQuery(), fc);
   
    List<FacetResult> facetResults = fc.getFacetResults();
    assertEquals("invalid number of facet results", 2, facetResults.size());
    for (FacetResult res : facetResults) {
      FacetResultNode root = res.getFacetResultNode();
View Full Code Here

TOP

Related Classes of org.apache.lucene.search.MatchAllDocsQuery

Copyright © 2018 www.massapicom. 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.