Package org.apache.lucene.facet.search

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


    TaxonomyReader tr = new LuceneTaxonomyReader(dirs[0][1]);

    // prepare searcher to search against
    IndexSearcher searcher = newSearcher(ir);

    FacetsCollector facetsCollector = performSearch(iParams, tr, ir,
        searcher);

    // Obtain facets results and hand-test them
    assertCorrectResults(facetsCollector);
View Full Code Here


    TaxonomyReader tr = new LuceneTaxonomyReader(dirs[0][1]);

    // prepare searcher to search against
    IndexSearcher searcher = newSearcher(ir);

    FacetsCollector facetsCollector = performSearch(iParams, tr, ir,
        searcher);

    // Obtain facets results and hand-test them
    assertCorrectResults(facetsCollector);
    assertPostingListExists("$facets", "$fulltree$", ir);
View Full Code Here

    TaxonomyReader tr = new LuceneTaxonomyReader(dirs[0][1]);

    // prepare searcher to search against
    IndexSearcher searcher = newSearcher(ir);

    FacetsCollector facetsCollector = performSearch(iParams, tr, ir,
        searcher);

    // Obtain facets results and hand-test them
    assertCorrectResults(facetsCollector);
    assertPostingListExists("$music", "music", ir);
View Full Code Here

        new CategoryPath("Author"), 10));
    facetSearchParams.addFacetRequest(new CountFacetRequest(
        new CategoryPath("Band", "Rock & Pop"), 10));

    // perform documents search and facets accumulation
    FacetsCollector facetsCollector = new FacetsCollector(facetSearchParams, ir, tr);
    searcher.search(q, MultiCollector.wrap(topDocsCollector, facetsCollector));
    return facetsCollector;
  }
View Full Code Here

    // application,
    // although it is insufficient for tight control on faceted search
    // behavior - in those
    // situations other, more low-level interfaces are available, as
    // demonstrated in other search examples.
    FacetsCollector facetsCollector = new FacetsCollector(
        facetSearchParams, indexReader, taxo);

    // perform documents search and facets accumulation
    searcher.search(q, MultiCollector.wrap(topDocsCollector, facetsCollector));

    // Obtain facets results and print them
    List<FacetResult> res = facetsCollector.getFacetResults();

    int i = 0;
    for (FacetResult facetResult : res) {
      ExampleUtils.log("Res " + (i++) + ": " + facetResult);
    }
View Full Code Here

      // facet counts and compare to control
      Query q = new TermQuery(new Term(CONTENT_FIELD, BETA)); // 90% of the docs
      ScoredDocIdCollector docCollector = ScoredDocIdCollector.create(searcher.maxDoc(), false);
     
      FacetSearchParams expectedSearchParams = searchParamsWithRequests(K, partitionSize);
      FacetsCollector fc = new FacetsCollector(expectedSearchParams, indexReader, taxoReader);
     
      searcher.search(q, MultiCollector.wrap(docCollector, fc));
     
      List<FacetResult> expectedResults = fc.getFacetResults();
     
      // complement with sampling!
      final Sampler sampler = createSampler(docCollector.getScoredDocIDs());
     
      FacetSearchParams samplingSearchParams = searchParamsWithRequests(K, partitionSize);
View Full Code Here

 
  private void assertSampling(List<FacetResult> expected, Query q, Sampler sampler, FacetSearchParams params, boolean complement) throws Exception {
    // 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
    for (int n=RETRIES; n>0; n--) {
      FacetsCollector samplingFC = samplingCollector(false, sampler, params);
     
      searcher.search(q, samplingFC);
      List<FacetResult> sampledResults = samplingFC.getFacetResults();
     
      try {
        assertSameResults(expected, sampledResults);
        break; // succeeded
      } catch (Exception e) {
View Full Code Here

 
  private FacetsCollector samplingCollector(
      final boolean complement,
      final Sampler sampler,
      FacetSearchParams samplingSearchParams) {
    FacetsCollector samplingFC = new FacetsCollector(samplingSearchParams, indexReader, taxoReader) {
      @Override
      protected FacetsAccumulator initFacetsAccumulator(
          FacetSearchParams facetSearchParams, IndexReader indexReader,
          TaxonomyReader taxonomyReader) {
        FacetsAccumulator acc = getSamplingAccumulator(sampler, taxonomyReader, indexReader, facetSearchParams);
View Full Code Here

      fRequests.add(fq);
    }

    TopScoreDocCollector topDocsCollector = TopScoreDocCollector.create(
        searcher.getIndexReader().maxDoc(), true);
    FacetsCollector facetsCollector = new FacetsCollector(
        facetSearchParams, searcher.getIndexReader(), taxonomyReader);
    Collector mColl = MultiCollector.wrap(topDocsCollector, facetsCollector);
   
    collectors[0] = topDocsCollector;
    collectors[1] = facetsCollector;
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 = new IndexSearcher(r);
    s.search(new MatchAllDocsQuery(), fcWithSampling);
   
    // there's only one expected result, return just it.
    return fcWithSampling.getFacetResults().get(0);
  }
View Full Code Here

TOP

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

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.