Package org.apache.lucene.facet.search.params

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


  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

        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

  }

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

    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

      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

      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

    for (int partitionSize : partitionSizes) {
      initIndex(partitionSize);

      CategoryPath path = new CategoryPath("Miau Hattulla");
      FacetSearchParams sParams = getFacetedSearchParams(partitionSize);
      sParams.addFacetRequest(new CountFacetRequest(path, 10));

      FacetsCollector fc = new FacetsCollector(sParams, indexReader, taxoReader);
     
      searcher.search(new MatchAllDocsQuery(), fc);
     
View Full Code Here

      ScoredDocIdCollector scoredDoc = ScoredDocIdCollector.create(is.maxDoc(), true);

      // Collector collector = new MultiCollector(scoredDoc);
      is.search(q, scoredDoc);

      CountFacetRequest cfra23 = new CountFacetRequest(
          new CategoryPath("a"), 2);
      cfra23.setDepth(3);
      cfra23.setResultMode(ResultMode.PER_NODE_IN_TREE);

      CountFacetRequest cfra22 = new CountFacetRequest(
          new CategoryPath("a"), 2);
      cfra22.setDepth(2);
      cfra22.setResultMode(ResultMode.PER_NODE_IN_TREE);

      CountFacetRequest cfra21 = new CountFacetRequest(
          new CategoryPath("a"), 2);
      cfra21.setDepth(1);
      cfra21.setResultMode(ResultMode.PER_NODE_IN_TREE);

      CountFacetRequest cfrb22 = new CountFacetRequest(
          new CategoryPath("a", "b"), 2);
      cfrb22.setDepth(2);
      cfrb22.setResultMode(ResultMode.PER_NODE_IN_TREE);

      CountFacetRequest cfrb23 = new CountFacetRequest(
          new CategoryPath("a", "b"), 2);
      cfrb23.setDepth(3);
      cfrb23.setResultMode(ResultMode.PER_NODE_IN_TREE);

      CountFacetRequest cfrb21 = new CountFacetRequest(
          new CategoryPath("a", "b"), 2);
      cfrb21.setDepth(1);
      cfrb21.setResultMode(ResultMode.PER_NODE_IN_TREE);

      CountFacetRequest doctor = new CountFacetRequest(
          new CategoryPath("Doctor"), 2);
      doctor.setDepth(1);
      doctor.setResultMode(ResultMode.PER_NODE_IN_TREE);

      CountFacetRequest cfrb20 = new CountFacetRequest(
          new CategoryPath("a", "b"), 2);
      cfrb20.setDepth(0);
      cfrb20.setResultMode(ResultMode.PER_NODE_IN_TREE);

      FacetSearchParams facetSearchParams = new FacetSearchParams(iParams);
      facetSearchParams.addFacetRequest(cfra23);
      facetSearchParams.addFacetRequest(cfra22);
      facetSearchParams.addFacetRequest(cfra21);
View Full Code Here

    return searchParamsWithRequests(numResults, Integer.MAX_VALUE);
  }
 
  protected FacetSearchParams searchParamsWithRequests(int numResults, int partitionSize) {
    FacetSearchParams res = getFacetedSearchParams(partitionSize);
    res.addFacetRequest(new CountFacetRequest(new CategoryPath("a"), numResults));
    res.addFacetRequest(new CountFacetRequest(new CategoryPath("a", "1"), numResults));
    res.addFacetRequest(new CountFacetRequest(new CategoryPath("a", "1", "10"), numResults));
    res.addFacetRequest(new CountFacetRequest(new CategoryPath("a", "2""26", "267"), numResults));
    return res;
  }
View Full Code Here

TOP

Related Classes of org.apache.lucene.facet.search.params.CountFacetRequest

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.