Examples of CountFacetRequest


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

    sp.setSamplingThreshold(50);
    sp.setOversampleFactor(5d);
   
    assertNull("Fixer should be null as the test is for no-fixing",
        sp.getSampleFixer());
    FacetSearchParams fsp = new FacetSearchParams(fip, new CountFacetRequest(
        new CategoryPath("root", "a"), 1));
    SamplingAccumulator accumulator = new SamplingAccumulator(
        new RandomSampler(sp, random()), fsp, indexReader, taxoReader);
   
    // Make sure no complements are in action
View Full Code Here

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

    assertEquals("Wrong number of top count aggregated categories no complement!",3,parentResNoComp.subResults.size());
  }
 
  /** 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);
   
View Full Code Here

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

    // NRT open
    IndexSearcher searcher = newSearcher(writer.getReader());
    writer.close();

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

    final boolean doDimCount = random().nextBoolean();

    CategoryListParams clp = new CategoryListParams() {
        @Override
View Full Code Here

Examples of org.apache.lucene.facet.search.params.CountFacetRequest

   */
  private FacetSearchParams getFacetSearchParams(TaxonomyAccessor taAccessor) {
    FacetSearchParams params = new FacetSearchParams();

    for (TaxonomyMapping map : taAccessor.getTaxonomyMappings()) {
      CountFacetRequest req = new CountFacetRequest(new CategoryPath(
          map.getCategory()), facetnumbercategories);
      params.addFacetRequest(req);
      if (log.isDebugEnabled()) {
        log.debug("Added Category Path " + map.getCategory().toString()
            + " to the Facet Search Params");
View Full Code Here

Examples of org.apache.lucene.facet.search.params.CountFacetRequest

  private void verifyResults(Directory dir, Directory taxDir) throws IOException {
    IndexReader reader1 = IndexReader.open(dir);
    LuceneTaxonomyReader taxReader = new LuceneTaxonomyReader(taxDir);
    IndexSearcher searcher = newSearcher(reader1);
    FacetSearchParams fsp = new FacetSearchParams();
    fsp.addFacetRequest(new CountFacetRequest(new CategoryPath("tag"), NUM_DOCS));
    FacetsCollector collector = new FacetsCollector(fsp, reader1, taxReader);
    searcher.search(new MatchAllDocsQuery(), collector);
    FacetResult result = collector.getFacetResults().get(0);
    FacetResultNode node = result.getFacetResultNode();
    for (FacetResultNode facet: node.getSubResults()) {
View Full Code Here

Examples of org.apache.lucene.facet.search.params.CountFacetRequest

        true);

    // Faceted search parameters indicate which facets are we interested in
    FacetSearchParams facetSearchParams = new FacetSearchParams(iParams);

    facetSearchParams.addFacetRequest(new CountFacetRequest(
        new CategoryPath("Band"), 10));
    CountFacetRequest bandDepth = new CountFacetRequest(new CategoryPath(
    "Band"), 10);
    bandDepth.setDepth(2);
    facetSearchParams.addFacetRequest(bandDepth);
    facetSearchParams.addFacetRequest(new CountFacetRequest(
        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));
View Full Code Here

Examples of org.apache.lucene.facet.search.params.CountFacetRequest

  }

  @Override
  protected FacetSearchParams getFacetedSearchParams() {
    FacetSearchParams res = super.getFacetedSearchParams();
    res.addFacetRequest(new CountFacetRequest(new CategoryPath("root","a"), 10));
    return res;
  }
View Full Code Here

Examples of org.apache.lucene.facet.search.params.CountFacetRequest

    TopScoreDocCollector topDocsCollector = TopScoreDocCollector.create(10,
        true);

    // Faceted search parameters indicate which facets are we interested in
    FacetSearchParams facetSearchParams = new FacetSearchParams(iParams);
    facetSearchParams.addFacetRequest(new CountFacetRequest(
        new CategoryPath("5"), 10));
    facetSearchParams.addFacetRequest(new CountFacetRequest(
        new CategoryPath("5", "5"), 10));
    facetSearchParams.addFacetRequest(new CountFacetRequest(
        new CategoryPath("6", "2"), 10));

    // Facets collector is the simplest interface for faceted search.
    // It provides faceted search functions that are sufficient to many
    // application,
View Full Code Here

Examples of org.apache.lucene.facet.search.params.CountFacetRequest

      initIndex(partitionSize);

      // do different facet counts and compare to control
      FacetSearchParams sParams = getFacetedSearchParams(partitionSize);
     
      sParams.addFacetRequest(new CountFacetRequest(new CategoryPath("a"), 100));
      CountFacetRequest cfra = new CountFacetRequest(new CategoryPath("a"), 100);
      cfra.setDepth(3);
      sParams.addFacetRequest(cfra);
      sParams.addFacetRequest(new CountFacetRequest(new CategoryPath("a", "b"), 100));
      sParams.addFacetRequest(new CountFacetRequest(new CategoryPath("a", "b", "1"), 100));
      sParams.addFacetRequest(new CountFacetRequest(new CategoryPath("a", "c"), 100));

      FacetsCollector fc = new FacetsCollector(sParams, indexReader, taxoReader) {
        @Override
        protected FacetsAccumulator initFacetsAccumulator(FacetSearchParams facetSearchParams, IndexReader indexReader, TaxonomyReader taxonomyReader) {
          FacetsAccumulator fa = new StandardFacetsAccumulator(facetSearchParams, indexReader, taxonomyReader);
View Full Code Here

Examples of org.apache.lucene.facet.search.params.CountFacetRequest

      initIndex(partitionSize);

      // do different facet counts and compare to control
      CategoryPath path = new CategoryPath("a", "b");
      FacetSearchParams sParams = getFacetedSearchParams(partitionSize);
      sParams.addFacetRequest(new CountFacetRequest(path, Integer.MAX_VALUE));

      FacetsCollector fc = new FacetsCollector(sParams, indexReader, taxoReader) {
        @Override
        protected FacetsAccumulator initFacetsAccumulator(FacetSearchParams facetSearchParams, IndexReader indexReader, TaxonomyReader taxonomyReader) {
          FacetsAccumulator fa = new StandardFacetsAccumulator(facetSearchParams, indexReader, taxonomyReader);
          fa.setComplementThreshold(FacetsAccumulator.DISABLE_COMPLEMENT);
          return fa;
        }
      };
     
      searcher.search(new MatchAllDocsQuery(), fc);
      long start = System.currentTimeMillis();
      List<FacetResult> results = fc.getFacetResults();
      long end = System.currentTimeMillis();

      if (VERBOSE) {
        System.out.println("Time: " + (end - start));
      }

      assertEquals("Should only be one result as there's only one request", 1, results.size());
      FacetResult res = results.get(0);
      assertEquals(path + " should only have 4 desendants", 4, res.getNumValidDescendants());

      // As a control base results, ask for top-1000 results
      FacetSearchParams sParams2 = getFacetedSearchParams(partitionSize);
      sParams2.addFacetRequest(new CountFacetRequest(path, Integer.MAX_VALUE));

      FacetsCollector fc2 = new FacetsCollector(sParams2, indexReader, taxoReader) {
        @Override
        protected FacetsAccumulator initFacetsAccumulator(FacetSearchParams facetSearchParams, IndexReader indexReader, TaxonomyReader taxonomyReader) {
          FacetsAccumulator fa = new StandardFacetsAccumulator(facetSearchParams, indexReader, taxonomyReader);
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.