Examples of FacetsCollector


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

    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(state, fsp));

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

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

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

  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());
    OldFacetsAccumulator 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

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

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

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

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

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

   
    // Make sure no complements are in action
    accumulator
        .setComplementThreshold(OldFacetsAccumulator.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

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

        new LongRange("less than or equal to 10", 0L, true, 10L, true),
        new LongRange("over 90", 90L, false, 100L, false),
        new LongRange("90 or above", 90L, true, 100L, false),
        new LongRange("over 1000", 1000L, false, Long.MAX_VALUE, true)));
   
    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 (1)\n", FacetTestUtils.toSimpleString(result.get(0)));
   
    r.close();
    d.close();
View Full Code Here

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

        new DoubleRange("less than or equal to 10", 0.0, true, 10.0, true),
        new DoubleRange("over 90", 90.0, false, 100.0, false),
        new DoubleRange("90 or above", 90.0, true, 100.0, false),
        new DoubleRange("over 1000", 1000.0, false, Double.POSITIVE_INFINITY, false)));
   
    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

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

        new FloatRange("less than or equal to 10", 0.0f, true, 10.0f, true),
        new FloatRange("over 90", 90.0f, false, 100.0f, false),
        new FloatRange("90 or above", 90.0f, true, 100.0f, false),
        new FloatRange("over 1000", 1000.0f, false, Float.POSITIVE_INFINITY, false)));
   
    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

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

            expectedCounts[rangeID]++;
          }
        }
      }

      FacetsCollector fc = FacetsCollector.create(new RangeAccumulator(new RangeFacetRequest<LongRange>("field", ranges)));
      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

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

            expectedCounts[rangeID]++;
          }
        }
      }

      FacetsCollector fc = FacetsCollector.create(new RangeAccumulator(new RangeFacetRequest<FloatRange>("field", ranges)));
      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
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.