Package org.apache.lucene.facet.search

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


    return ordinal / partitionSize == offset / partitionSize;
  }
 
  @Override
  public final FacetResult compute() throws IOException {
    FacetResult res = renderFacetResult(fetchPartitionResult(0));
    labelResult(res);
    return res;
  }
View Full Code Here


        }

        FacetResultNode rootNode = new FacetResultNode(-1, dimCount);
        rootNode.label = new CategoryPath(new String[] {dim});
        rootNode.subResults = nodes;
        results.add(new FacetResult(request, rootNode, nodes.size()));
        continue;
      }

      TopCountPQ q = new TopCountPQ(request.numResults);

      int bottomCount = 0;

      //System.out.println("collect");
      int dimCount = 0;
      int childCount = 0;
      FacetResultNode reuse = null;
      for(int ord=ordRange.start; ord<=ordRange.end; ord++) {
        //System.out.println("  ord=" + ord + " count= "+ counts[ord] + " bottomCount=" + bottomCount);
        if (counts[ord] > 0) {
          childCount++;
          if (counts[ord] > bottomCount) {
            dimCount += counts[ord];
            //System.out.println("    keep");
            if (reuse == null) {
              reuse = new FacetResultNode(ord, counts[ord]);
            } else {
              reuse.ordinal = ord;
              reuse.value = counts[ord];
            }
            reuse = q.insertWithOverflow(reuse);
            if (q.size() == request.numResults) {
              bottomCount = (int) q.top().value;
              //System.out.println("    new bottom=" + bottomCount);
            }
          }
        }
      }

      CategoryListParams.OrdinalPolicy op = searchParams.indexingParams.getCategoryListParams(request.categoryPath).getOrdinalPolicy(dim);
      if (op == CategoryListParams.OrdinalPolicy.ALL_BUT_DIMENSION) {
        dimCount = 0;
      }

      FacetResultNode rootNode = new FacetResultNode(-1, dimCount);
      rootNode.label = new CategoryPath(new String[] {dim});

      FacetResultNode[] childNodes = new FacetResultNode[q.size()];
      for(int i=childNodes.length-1;i>=0;i--) {
        childNodes[i] = q.pop();
        dv.lookupOrd(childNodes[i].ordinal, scratch);
        childNodes[i].label = new CategoryPath(scratch.utf8ToString().split(state.separatorRegex, 2));
      }
      rootNode.subResults = Arrays.asList(childNodes);
     
      results.add(new FacetResult(request, rootNode, childCount));
    }

    return results;
  }
View Full Code Here

    FacetRequest origFrq = sampledFreq.orig;

    FacetResultNode trimmedRootNode = facetResult.getFacetResultNode();
    trimSubResults(trimmedRootNode, origFrq.numResults);
   
    return new FacetResult(origFrq, trimmedRootNode, facetResult.getNumValidDescendants());
  }
View Full Code Here

     
      FacetResultNode rootNode = new FacetResultNode(-1, 0);
      rootNode.label = rangeFR.categoryPath;
      rootNode.subResults = nodes;

      results.add(new FacetResult(req, rootNode, nodes.size()));
    }
   
    return results;
  }
View Full Code Here

        if (tmpResult == null) {
          // Add empty FacetResult:
          res.add(emptyResult(taxonomyReader.getOrdinal(fr.categoryPath), fr));
          continue;
        }
        FacetResult facetRes = frHndlr.renderFacetResult(tmpResult);
        // final labeling if allowed (because labeling is a costly operation)
        frHndlr.labelResult(facetRes);
        res.add(facetRes);
      }
View Full Code Here

  /** Validate results equality */
  protected static void assertSameResults(List<FacetResult> expected, List<FacetResult> actual) {
    assertEquals("wrong number of facet results", expected.size(), actual.size());
    int size = expected.size();
    for (int i = 0; i < size; i++) {
      FacetResult expectedResult = expected.get(i);
      FacetResult actualResult = actual.get(i);
      String expectedStr = FacetTestUtils.toSimpleString(expectedResult);
      String actualStr = FacetTestUtils.toSimpleString(actualResult);
      assertEquals("Results not the same!\nExpected:" + expectedStr + "\nActual:\n" + actualStr, expectedStr, actualStr);
    }
  }
View Full Code Here

    params.setMaxSampleSize(50);
    params.setOversampleFactor(5);
    params.setSamplingThreshold(60);
    params.setSampleRatio(0.1);
   
    FacetResult res = searchWithFacets(r, tr, fsp, params);
    FacetRequest req = res.getFacetRequest();
    assertEquals(facetRequest, req);
   
    FacetResultNode rootNode = res.getFacetResultNode();
   
    // Each node below root should also have sub-results as the requested depth was '2'
    for (FacetResultNode node : rootNode.subResults) {
      assertTrue("node " + node.label + " should have had children as the requested depth was '2'", node.subResults.size() > 0);
    }
View Full Code Here

    DirectoryTaxonomyReader taxReader = new DirectoryTaxonomyReader(taxDir);
    IndexSearcher searcher = newSearcher(reader1);
    FacetSearchParams fsp = new FacetSearchParams(fip, new CountFacetRequest(new CategoryPath("tag"), NUM_DOCS));
    FacetsCollector collector = FacetsCollector.create(fsp, reader1, taxReader);
    searcher.search(new MatchAllDocsQuery(), collector);
    FacetResult result = collector.getFacetResults().get(0);
    FacetResultNode node = result.getFacetResultNode();
    for (FacetResultNode facet: node.subResults) {
      int weight = (int)facet.value;
      int label = Integer.parseInt(facet.label.components[1]);
      //System.out.println(label + ": " + weight);
      if (VERBOSE) {
View Full Code Here

    params.setMaxSampleSize(50);
    params.setOversampleFactor(5);
    params.setSamplingThreshold(60);
    params.setSampleRatio(0.1);
   
    FacetResult res = searchWithFacets(r, tr, fsp, params);
    FacetRequest req = res.getFacetRequest();
    assertEquals(facetRequest, req);
   
    FacetResultNode rootNode = res.getFacetResultNode();
   
    // Each node below root should also have sub-results as the requested depth was '2'
    for (FacetResultNode node : rootNode.subResults) {
      assertTrue("node " + node.label + " should have had children as the requested depth was '2'", node.subResults.size() > 0);
    }
View Full Code Here

      FacetResultNode rootNode = new FacetResultNode(-1, 0);
      rootNode.label = new CategoryPath(ranges.field);
      rootNode.subResults = nodes;

      results.add(new FacetResult(searchParams.facetRequests.get(i), rootNode, nodes.size()));
    }

    return results;
  }
View Full Code Here

TOP

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

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.