Package org.apache.lucene.facet.taxonomy

Examples of org.apache.lucene.facet.taxonomy.TaxonomyReader$ChildrenIterator


    IndexReader ir = iw.getReader();
    tw.commit();

    // prepare index reader and taxonomy.
    TaxonomyReader tr = new DirectoryTaxonomyReader(taxoDir);

    // prepare searcher to search against
    IndexSearcher searcher = newSearcher(ir);

    FacetsCollector sfc = performSearch(tr, ir, searcher);
View Full Code Here


  /** Search an index with a sum of int-association. */
  public static List<FacetResult> searchSumIntAssociation(Directory indexDir,
      Directory taxoDir) throws Exception {
    // prepare index reader
    IndexReader indexReader = IndexReader.open(indexDir);
    TaxonomyReader taxo = new LuceneTaxonomyReader(taxoDir);
   
    AssociationIntSumFacetRequest facetRequest = new AssociationIntSumFacetRequest(
        new CategoryPath("tags"), 10);
   
    List<FacetResult> res = SimpleSearcher.searchWithRequest(indexReader, taxo,
        AssociationUtils.assocIndexingParams, facetRequest);
   
    // close readers
    taxo.close();
    indexReader.close();
   
    return res;
  }
View Full Code Here

  /** Search an index with a sum of float-association. */
  public static List<FacetResult> searchSumFloatAssociation(Directory indexDir,
      Directory taxoDir) throws Exception {
    // prepare index reader
    IndexReader indexReader = IndexReader.open(indexDir);
    TaxonomyReader taxo = new LuceneTaxonomyReader(taxoDir);
   
    AssociationFloatSumFacetRequest facetRequest = new AssociationFloatSumFacetRequest(
        new CategoryPath("genre"), 10);
   
    List<FacetResult> res = SimpleSearcher.searchWithRequest(indexReader, taxo,
        AssociationUtils.assocIndexingParams, facetRequest);
   
    // close readers
    taxo.close();
    indexReader.close();
   
    return res;
  }
View Full Code Here

    // index the sample documents
    ExampleUtils.log("index the sample documents...");
    SimpleIndexer.index(indexDir, taxoDir);

    // open readers
    TaxonomyReader taxo = new LuceneTaxonomyReader(taxoDir);
    IndexReader indexReader = IndexReader.open(indexDir, true);

    ExampleUtils.log("search the sample documents...");
    List<FacetResult> facetRes = SimpleSearcher.searchWithFacets(indexReader, taxo);

    // close readers
    taxo.close();
    indexReader.close();
   
    ExampleResult res = new ExampleResult();
    res.setFacetResults(facetRes);
    return res;
View Full Code Here

    // index the sample documents
    ExampleUtils.log("index the sample documents...");
    SimpleIndexer.index(indexDir, taxoDir);

    // open readers
    TaxonomyReader taxo = new LuceneTaxonomyReader(taxoDir);
    IndexReader indexReader = IndexReader.open(indexDir, true);

    ExampleUtils.log("search the sample documents...");
    List<FacetResult> facetRes = SimpleSearcher.searchWithDrillDown(indexReader, taxo);
   
    // close readers
    taxo.close();
    indexReader.close();
   
    ExampleResult res = new ExampleResult();
    res.setFacetResults(facetRes);
    return res;
View Full Code Here

    FacetIndexingParams iParams = new DefaultFacetIndexingParams(clp);
    Directory indexDir = newDirectory();
    Directory taxoDir = newDirectory();
    populateIndex(iParams, indexDir, taxoDir);

    TaxonomyReader taxo = new LuceneTaxonomyReader(taxoDir);
    IndexReader reader = IndexReader.open(indexDir);

    CategoryListCache clCache = null;
    if (cacheCLI) {
      // caching the iteratorr, so:
      // 1: create the cached iterator, using original params
      clCache = new CategoryListCache();
      clCache.loadAndRegister(clp, reader, taxo, iParams);
    }
   
    ScoredDocIDs allDocs = ScoredDocIdsUtils
        .createAllDocsScoredDocIDs(reader);

    // Search index with 'author' should filter ONLY ordinals whose parent
    // is 'author'
    countForbiddenDimension = "date";
    validateFacetedSearch(iParams, taxo, reader, clCache, allDocs, "author", 5, 5);

    // Search index with 'date' should filter ONLY ordinals whose parent is
    // 'date'
    countForbiddenDimension = "author";
    validateFacetedSearch(iParams, taxo, reader, clCache, allDocs, "date", 5, 2);

    // Search index with both 'date' and 'author'
    countForbiddenDimension = null;
    validateFacetedSearch(iParams, taxo, reader, clCache, allDocs, new String[] {
            "author", "date" }, new int[] { 5, 5 }, new int[] { 5, 2 });
    taxo.close();
    reader.close();
    indexDir.close();
    taxoDir.close();
  }
View Full Code Here

    IndexReader ir = iw.getReader();
    tw.commit();

    // prepare index reader and taxonomy.
    TaxonomyReader tr = new LuceneTaxonomyReader(dirs[0][1]);

    // prepare searcher to search against
    IndexSearcher searcher = newSearcher(ir);

    FacetsCollector facetsCollector = performSearch(iParams, tr, ir,
        searcher);

    // Obtain facets results and hand-test them
    assertCorrectResults(facetsCollector);

    TermDocs td = ir.termDocs(new Term("$facets", "$fulltree$"));
    assertTrue(td.next());

    tr.close();
    ir.close();
    searcher.close();
    iw.close();
    tw.close();
    IOUtils.close(dirs[0]);
View Full Code Here

    IndexReader ir = iw.getReader();
    tw.commit();

    // prepare index reader and taxonomy.
    TaxonomyReader tr = new LuceneTaxonomyReader(dirs[0][1]);

    // prepare searcher to search against
    IndexSearcher searcher = newSearcher(ir);

    FacetsCollector facetsCollector = performSearch(iParams, tr, ir,
        searcher);

    // Obtain facets results and hand-test them
    assertCorrectResults(facetsCollector);

    assertPostingListExists("$facets", "$fulltree$", ir);
    assertPostingListExists("$author", "Authors", ir);

    tr.close();
    ir.close();
    searcher.close();
    iw.close();
    tw.close();
    IOUtils.close(dirs[0]);
View Full Code Here

    IndexReader ir = iw.getReader();
    tw.commit();

    // prepare index reader and taxonomy.
    TaxonomyReader tr = new LuceneTaxonomyReader(dirs[0][1]);

    // prepare searcher to search against
    IndexSearcher searcher = newSearcher(ir);

    FacetsCollector facetsCollector = performSearch(iParams, tr, ir,
        searcher);

    // Obtain facets results and hand-test them
    assertCorrectResults(facetsCollector);

    assertPostingListExists("$facets", "$fulltree$", ir);
    assertPostingListExists("$music", "Bands", ir);
    assertPostingListExists("$music", "Composers", ir);

    tr.close();
    ir.close();
    searcher.close();
    iw.close();
    tw.close();
    IOUtils.close(dirs[0]);
View Full Code Here

    IndexReader ir = iw.getReader();
    tw.commit();

    // prepare index reader and taxonomy.
    TaxonomyReader tr = new LuceneTaxonomyReader(dirs[0][1]);

    // prepare searcher to search against
    IndexSearcher searcher = newSearcher(ir);

    FacetsCollector facetsCollector = performSearch(iParams, tr, ir,
        searcher);

    // Obtain facets results and hand-test them
    assertCorrectResults(facetsCollector);
    assertPostingListExists("$facets", "$fulltree$", ir);
    assertPostingListExists("$bands", "Bands", ir);
    assertPostingListExists("$composers", "Composers", ir);
    tr.close();
    ir.close();
    searcher.close();
    iw.close();
    tw.close();
    IOUtils.close(dirs[0]);
View Full Code Here

TOP

Related Classes of org.apache.lucene.facet.taxonomy.TaxonomyReader$ChildrenIterator

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.