Package org.apache.lucene.facet.search

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


                                                      new FloatRange("90 or above", 90.0f, true, 100.0f, false),
                                                      new FloatRange("over 1000", 1000.0f, false, Float.POSITIVE_INFINITY, false)));

    RangeAccumulator a = new RangeAccumulator(fsp, r);
   
    FacetsCollector fc = FacetsCollector.create(a);

    IndexSearcher s = newSearcher(r);
    s.search(new MatchAllDocsQuery(), fc);
    List<FacetResult> result = fc.getFacetResults();
    assertEquals(1, result.size());
    assertEquals("field (0)\n  less than 10 (10)\n  less than or equal to 10 (11)\n  over 90 (9)\n  90 or above (10)\n  over 1000 (0)\n", FacetTestUtils.toSimpleString(result.get(0)));
   
    r.close();
    d.close();
View Full Code Here


          }
        }
      }

      FacetSearchParams fsp = new FacetSearchParams(new RangeFacetRequest<LongRange>("field", ranges));
      FacetsCollector fc = FacetsCollector.create(new RangeAccumulator(fsp, r));
      s.search(new MatchAllDocsQuery(), fc);
      List<FacetResult> results = fc.getFacetResults();
      assertEquals(1, results.size());
      List<FacetResultNode> nodes = results.get(0).getFacetResultNode().subResults;
      assertEquals(numRange, nodes.size());
      for(int rangeID=0;rangeID<numRange;rangeID++) {
        if (VERBOSE) {
View Full Code Here

          }
        }
      }

      FacetSearchParams fsp = new FacetSearchParams(new RangeFacetRequest<FloatRange>("field", ranges));
      FacetsCollector fc = FacetsCollector.create(new RangeAccumulator(fsp, r));
      s.search(new MatchAllDocsQuery(), fc);
      List<FacetResult> results = fc.getFacetResults();
      assertEquals(1, results.size());
      List<FacetResultNode> nodes = results.get(0).getFacetResultNode().subResults;
      assertEquals(numRange, nodes.size());
      for(int rangeID=0;rangeID<numRange;rangeID++) {
        if (VERBOSE) {
View Full Code Here

          }
        }
      }

      FacetSearchParams fsp = new FacetSearchParams(new RangeFacetRequest<DoubleRange>("field", ranges));
      FacetsCollector fc = FacetsCollector.create(new RangeAccumulator(fsp, r));
      s.search(new MatchAllDocsQuery(), fc);
      List<FacetResult> results = fc.getFacetResults();
      assertEquals(1, results.size());
      List<FacetResultNode> nodes = results.get(0).getFacetResultNode().subResults;
      assertEquals(numRange, nodes.size());
      for(int rangeID=0;rangeID<numRange;rangeID++) {
        if (VERBOSE) {
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

   
    // Make sure no complements are in action
    accumulator
        .setComplementThreshold(StandardFacetsAccumulator.DISABLE_COMPLEMENT);
   
    FacetsCollector fc = FacetsCollector.create(accumulator);
   
    searcher.search(new MatchAllDocsQuery(), fc);
    FacetResultNode node = fc.getFacetResults().get(0).getFacetResultNode();
   
    assertTrue(node.value < numDocsToIndex());
  }
View Full Code Here

                                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(fsp, searcher.getIndexReader()));

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

  /** compute facets with certain facet requests and docs */
  private List<FacetResult> findFacets(boolean withComplement) throws IOException {
    FacetSearchParams fsp = new FacetSearchParams(fip, new CountFacetRequest(new CategoryPath("root","a"), 10));
    StandardFacetsAccumulator sfa = new StandardFacetsAccumulator(fsp, indexReader, taxoReader);
    sfa.setComplementThreshold(withComplement ? StandardFacetsAccumulator.FORCE_COMPLEMENT : StandardFacetsAccumulator.DISABLE_COMPLEMENT);
    FacetsCollector fc = FacetsCollector.create(sfa);
    searcher.search(new MatchAllDocsQuery(), fc);
   
    List<FacetResult> res = fc.getFacetResults();
   
    // Results are ready, printing them...
    int i = 0;
    if (VERBOSE) {
      for (FacetResult facetResult : res) {
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

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.