Package org.apache.lucene.index

Examples of org.apache.lucene.index.DirectoryReader$MultiTermDocs


    facetFields.addFields(doc, Arrays.asList(new CategoryPath("A", "2")));
    writer.addDocument(doc);
    writer.close();
    taxoWriter.close();
   
    final DirectoryReader reader = DirectoryReader.open(indexDir);
    Thread[] threads = new Thread[3];
    for (int i = 0; i < threads.length; i++) {
      threads[i] = new Thread("CachedOrdsThread-" + i) {
        @Override
        public void run() {
          for (AtomicReaderContext context : reader.leaves()) {
            try {
              OrdinalsCache.getCachedOrds(context, FacetIndexingParams.DEFAULT.getCategoryListParams(new CategoryPath("A")));
            } catch (IOException e) {
              throw new RuntimeException(e);
            }
          }
        }
      };
    }

    OrdinalsCache.clear();

    long ramBytesUsed = 0;
    for (Thread t : threads) {
      t.start();
      t.join();
      if (ramBytesUsed == 0) {
        ramBytesUsed = OrdinalsCache.ramBytesUsed();
      } else {
        assertEquals(ramBytesUsed, OrdinalsCache.ramBytesUsed());
      }
    }
   
    reader.close();
   
    IOUtils.close(indexDir, taxoDir);
  }
View Full Code Here


    }
   
    taxonomyWriter.close();
    iw.close();
   
    DirectoryReader r = DirectoryReader.open(indexDir);
    DirectoryTaxonomyReader taxo = new DirectoryTaxonomyReader(taxoDir);
   
    FacetSearchParams fsp = new FacetSearchParams(new SumScoreFacetRequest(new CategoryPath("a"), 10));
    FacetsCollector fc = FacetsCollector.create(fsp, r, taxo);
    TopScoreDocCollector topDocs = TopScoreDocCollector.create(10, false);
View Full Code Here

    }
   
    taxonomyWriter.close();
    iw.close();
   
    DirectoryReader r = DirectoryReader.open(indexDir);
    DirectoryTaxonomyReader taxo = new DirectoryTaxonomyReader(taxoDir);
   
    FacetSearchParams sParams = new FacetSearchParams(fip,
        new CountFacetRequest(new CategoryPath("a"), 10),
        new CountFacetRequest(new CategoryPath("b"), 10));
    FacetsCollector fc = FacetsCollector.create(sParams, r, taxo);
    newSearcher(r).search(new MatchAllDocsQuery(), fc);
   
    for (FacetResult res : fc.getFacetResults()) {
      assertEquals("unexpected count for " + res, r.maxDoc(), (int) res.getFacetResultNode().value);
    }
   
    IOUtils.close(taxo, taxoDir, r, indexDir);
  }
View Full Code Here

    }
   
    taxonomyWriter.close();
    iw.close();
   
    DirectoryReader r = DirectoryReader.open(indexDir);
    DirectoryTaxonomyReader taxo = new DirectoryTaxonomyReader(taxoDir);
   
    FacetSearchParams sParams = new FacetSearchParams(fip,
        new CountFacetRequest(new CategoryPath("a"), 10),
        new SumScoreFacetRequest(new CategoryPath("b"), 10));
   
    FacetsCollector fc = FacetsCollector.create(sParams, r, taxo);
    TopScoreDocCollector topDocs = TopScoreDocCollector.create(10, false);
    newSearcher(r).search(new MatchAllDocsQuery(), MultiCollector.wrap(fc, topDocs));
   
    List<FacetResult> facetResults = fc.getFacetResults();
    FacetResult fresA = facetResults.get(0);
    assertEquals("unexpected count for " + fresA, r.maxDoc(), (int) fresA.getFacetResultNode().value);
   
    FacetResult fresB = facetResults.get(1);
    double expected = topDocs.topDocs().getMaxScore() * r.numDocs();
    assertEquals("unexpected value for " + fresB, expected, fresB.getFacetResultNode().value, 1E-10);
   
    IOUtils.close(taxo, taxoDir, r, indexDir);
  }
View Full Code Here

    }
   
    taxonomyWriter.close();
    iw.close();
   
    DirectoryReader r = DirectoryReader.open(indexDir);
    DirectoryTaxonomyReader taxo = new DirectoryTaxonomyReader(taxoDir);
   
    FacetSearchParams fsp = new FacetSearchParams(new CountFacetRequest(CategoryPath.EMPTY, 10));
   
    final TaxonomyFacetsAccumulator fa = random().nextBoolean() ? new TaxonomyFacetsAccumulator(fsp, r, taxo) : new OldFacetsAccumulator(fsp, r, taxo);
    FacetsCollector fc = FacetsCollector.create(fa);
    newSearcher(r).search(new MatchAllDocsQuery(), fc);
   
    FacetResult res = fc.getFacetResults().get(0);
    for (FacetResultNode node : res.getFacetResultNode().subResults) {
      assertEquals(r.numDocs(), (int) node.value);
    }
   
    IOUtils.close(taxo, taxoDir, r, indexDir);
  }
View Full Code Here

    facetFields.addFields(doc, Arrays.asList(new CategoryPath("a/1", '/'), new CategoryPath("b/1", '/')));
    iw.addDocument(doc);
    taxonomyWriter.close();
    iw.close();
   
    DirectoryReader r = DirectoryReader.open(indexDir);
    DirectoryTaxonomyReader taxo = new DirectoryTaxonomyReader(taxoDir);
   
    FacetSearchParams fsp = new FacetSearchParams(
        new CountFacetRequest(new CategoryPath("a"), 10),
        new CountFacetRequest(new CategoryPath("b"), 10));
View Full Code Here

    facetFields.addFields(doc, Arrays.asList(new CategoryPath("a/1", '/'), new CategoryPath("b/1", '/')));
    iw.addDocument(doc);
    taxonomyWriter.close();
    iw.close();
   
    DirectoryReader r = DirectoryReader.open(indexDir);
    DirectoryTaxonomyReader taxo = new DirectoryTaxonomyReader(taxoDir);
   
    FacetSearchParams fsp = new FacetSearchParams(
        new CountFacetRequest(new CategoryPath("a"), 10),
        new CountFacetRequest(new CategoryPath("b"), 10));
View Full Code Here

    facetFields.addFields(doc, Arrays.asList(new CategoryPath("a/1", '/')));
    iw.addDocument(doc);
    taxonomyWriter.close();
    iw.close();
   
    DirectoryReader r = DirectoryReader.open(indexDir);
    DirectoryTaxonomyReader taxo = new DirectoryTaxonomyReader(taxoDir);

    // assert IntFacetResultHandler
    FacetSearchParams fsp = new FacetSearchParams(new CountFacetRequest(new CategoryPath("a"), 10));
    TaxonomyFacetsAccumulator fa = random().nextBoolean() ? new TaxonomyFacetsAccumulator(fsp, r, taxo) : new OldFacetsAccumulator(fsp, r, taxo);
View Full Code Here

    }
   
    taxonomyWriter.close();
    iw.close();
   
    DirectoryReader r = DirectoryReader.open(indexDir);
    DirectoryTaxonomyReader taxo = new DirectoryTaxonomyReader(taxoDir);
   
    CountFacetRequest cfr = new CountFacetRequest(new CategoryPath("a"), 2);
    cfr.setResultMode(random().nextBoolean() ? ResultMode.GLOBAL_FLAT : ResultMode.PER_NODE_IN_TREE);
    FacetSearchParams fsp = new FacetSearchParams(cfr);
View Full Code Here

    Document doc = new Document();
    facetFields.addFields(doc, Arrays.asList(new CategoryPath("A/1", '/')));
    indexWriter.addDocument(doc);
    IOUtils.close(indexWriter, taxoWriter);
   
    DirectoryReader indexReader = DirectoryReader.open(indexDir);
    TaxonomyReader taxoReader = new DirectoryTaxonomyReader(taxoDir);
    IndexSearcher searcher = new IndexSearcher(indexReader);
    // ask to count a non-existing category to test labeling
    FacetSearchParams fsp = new FacetSearchParams(new CountFacetRequest(new CategoryPath("B"), 5));
   
View Full Code Here

TOP

Related Classes of org.apache.lucene.index.DirectoryReader$MultiTermDocs

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.