Package org.apache.lucene.facet.search

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


    List<FacetRequest> requests = new ArrayList<FacetRequest>();
    requests.add(new CountFacetRequest(new CategoryPath("a"), 10));

    FacetSearchParams fsp = new FacetSearchParams(requests);
   
    FacetsCollector c = FacetsCollector.create(new SortedSetDocValuesAccumulator(fsp, state));

    searcher.search(new MatchAllDocsQuery(), c);

    try {
      c.getFacetResults();
      fail("did not hit expected exception");
    } catch (IllegalStateException ise) {
      // expected
    }
View Full Code Here


    FacetSearchParams fsp = new FacetSearchParams(
        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

    // 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

      public FacetsAggregator getAggregator() {
        return new SumIntAssociationFacetsAggregator();
      }
    };
   
    FacetsCollector fc = FacetsCollector.create(fa);
   
    IndexSearcher searcher = newSearcher(reader);
    searcher.search(q, fc);
    List<FacetResult> res = fc.getFacetResults();
   
    assertNotNull("No results!",res);
    assertEquals("Wrong number of results!",2, res.size());
    assertEquals("Wrong count for category 'a'!", 200, (int) res.get(0).getFacetResultNode().value);
    assertEquals("Wrong count for category 'b'!", 150, (int) res.get(1).getFacetResultNode().value);
View Full Code Here

      public FacetsAggregator getAggregator() {
        return new SumFloatAssociationFacetsAggregator();
      }
    };
   
    FacetsCollector fc = FacetsCollector.create(fa);
   
    IndexSearcher searcher = newSearcher(reader);
    searcher.search(q, fc);
    List<FacetResult> res = fc.getFacetResults();
   
    assertNotNull("No results!",res);
    assertEquals("Wrong number of results!", 2, res.size());
    assertEquals("Wrong count for category 'a'!",50f, (float) res.get(0).getFacetResultNode().value, 0.00001);
    assertEquals("Wrong count for category 'b'!",10f, (float) res.get(1).getFacetResultNode().value, 0.00001);
View Full Code Here

      @Override
      public FacetsAggregator getAggregator() {
        return new MultiAssociationsFacetsAggregator(aggregators);
      }
    };
    FacetsCollector fc = FacetsCollector.create(fa);
   
    IndexSearcher searcher = newSearcher(reader);
    searcher.search(q, fc);
    List<FacetResult> res = fc.getFacetResults();
   
    assertEquals("Wrong number of results!", 4, res.size());
    assertEquals("Wrong count for category 'a'!", 200, (int) res.get(0).getFacetResultNode().value);
    assertEquals("Wrong count for category 'b'!", 150, (int) res.get(1).getFacetResultNode().value);
    assertEquals("Wrong count for category 'a'!",50f, (float) res.get(2).getFacetResultNode().value, 0.00001);
View Full Code Here

    SortedSetDocValuesReaderState state = new SortedSetDocValuesReaderState(fip, searcher.getIndexReader());
   
    //SortedSetDocValuesCollector c = new SortedSetDocValuesCollector(state);
    //SortedSetDocValuesCollectorMergeBySeg c = new SortedSetDocValuesCollectorMergeBySeg(state);

    FacetsCollector c = FacetsCollector.create(new SortedSetDocValuesAccumulator(fsp, state));

    searcher.search(new MatchAllDocsQuery(), c);

    //List<FacetResult> results = c.getFacetResults(requests);
    List<FacetResult> results = c.getFacetResults();

    assertEquals(3, results.size());

    int dimCount = doDimCount ? 4 : 0;
    assertEquals("a (" + dimCount + ")\n  foo (2)\n  bar (1)\n  zoo (1)\n", FacetTestUtils.toSimpleString(results.get(0)));
View Full Code Here

  private FacetResult searchWithFacets(IndexReader r, TaxonomyReader tr, FacetSearchParams fsp,
      final SamplingParams params) throws IOException {
    // a FacetsCollector with a sampling accumulator
    Sampler sampler = new RandomSampler(params, random());
    StandardFacetsAccumulator sfa = new SamplingAccumulator(sampler, fsp, r, tr);
    FacetsCollector fcWithSampling = FacetsCollector.create(sfa);
   
    IndexSearcher s = newSearcher(r);
    s.search(new MatchAllDocsQuery(), fcWithSampling);
   
    // there's only one expected result, return just it.
    return fcWithSampling.getFacetResults().get(0);
  }
View Full Code Here

        // Get all of the documents and run the query, then do different
        // facet counts and compare to control
        Query q = new TermQuery(new Term(CONTENT_FIELD, BETA)); // 90% of the docs
       
        FacetSearchParams expectedSearchParams = searchParamsWithRequests(K, fip);
        FacetsCollector fc = FacetsCollector.create(expectedSearchParams, indexReader, taxoReader);
       
        searcher.search(q, fc);
       
        List<FacetResult> expectedResults = fc.getFacetResults();
       
        FacetSearchParams samplingSearchParams = searchParamsWithRequests(K, fip);
       
        // try several times in case of failure, because the test has a chance to fail
        // if the top K facets are not sufficiently common with the sample set
View Full Code Here

      }
    }
  }
 
  private void assertSampling(List<FacetResult> expected, Query q, Sampler sampler, FacetSearchParams params, boolean complement) throws Exception {
    FacetsCollector samplingFC = samplingCollector(complement, sampler, params);
   
    searcher.search(q, samplingFC);
    List<FacetResult> sampledResults = samplingFC.getFacetResults();
   
    assertSameResults(expected, sampledResults);
  }
View Full Code Here

TOP

Related Classes of org.apache.lucene.facet.search.FacetsCollector$DocsOnlyCollector

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.