Package org.apache.lucene.index

Examples of org.apache.lucene.index.MultiReader


   * Test that complements works with MultiReader
   */
  @Test
  public void testComplementsWithMultiReader() throws Exception {
    final IndexReader origReader = indexReader;
    indexReader = new MultiReader(origReader);
    try {
      doTestComplements();
    } finally {
      indexReader = origReader;
    }
View Full Code Here


    }
   
    IndexWriter writer = new IndexWriter(indexDir, newIndexWriterConfig(TEST_VERSION_CURRENT, null));
    writer.deleteAll();
    try {
      writer.addIndexes(new MultiReader(wrappedLeaves));
      writer.commit();
    } finally {
      reader.close();
      writer.close();
    }
View Full Code Here

    d.close();
  }
 
  /** test sorts when there's nothing in the index */
  public void testEmptyIndex() throws Exception {
    IndexSearcher empty = newSearcher(new MultiReader());
    Query query = new TermQuery(new Term("contents", "foo"));
 
    Sort sort = new Sort();
    TopDocs td = empty.search(query, null, 10, sort, true, true);
    assertEquals(0, td.totalHits);
View Full Code Here

    AtomicReader wrappedLeaves[] = new AtomicReader[numReaders];
    for (int i = 0; i < numReaders; i++) {
      wrappedLeaves[i] = new OrdinalMappingAtomicReader(leaves.get(i).reader(), ordinalMap, params);
    }
    try {
      destIndexWriter.addIndexes(new MultiReader(wrappedLeaves));
     
      // commit changes to taxonomy and index respectively.
      destTaxWriter.commit();
      destIndexWriter.commit();
    } finally {
View Full Code Here

    IndexReader in;
    if (inputs.size() == 1) {
      in = inputs.get(0);
    } else {
      //in = new MultiReader((IndexReader[])inputs.toArray(new IndexReader[inputs.size()]), true);
      in = new MultiReader((IndexReader[])inputs.toArray(new IndexReader[inputs.size()]));
    }
    if (in.hasDeletions()) {
      System.err.println("WARN: input index(es) with deletions - document ID-s will NOT be preserved!");
    }
    IndexReader pruning = null;
View Full Code Here

    this.conf = conf;
    this.fs = FileSystem.get(conf);
    for (int i = 0; i < indexDirs.length; i++) {
      readers[i] = IndexReader.open(getDirectory(indexDirs[i]));
    }
    init(new MultiReader(readers), conf, blacklistFile);
  }
View Full Code Here

    w2.addDocument(doc);
    IndexReader reader2 = w2.getReader();
    w2.close();
   
    TermsFilter tf = new TermsFilter(new Term(fieldName, "content1"));
    MultiReader multi = new MultiReader(reader1, reader2);
    for (AtomicReaderContext context : multi.leaves()) {
      DocIdSet docIdSet = tf.getDocIdSet(context, context.reader().getLiveDocs());
      if (context.reader().docFreq(new Term(fieldName, "content1")) == 0) {
        assertNull(docIdSet);
      } else {
        FixedBitSet bits = (FixedBitSet) docIdSet;
        assertTrue("Must be >= 0", bits.cardinality() >= 0);     
      }
    }
    multi.close();
    reader1.close();
    reader2.close();
    rd1.close();
    rd2.close();
  }
View Full Code Here

            new FsDirectory(fs, stats[i].getPath(), false, conf,
                    new DataReporter(stats[i].getPath()), bufferSize);
          IndexReader reader = DirectoryReader.open(fsdir);
          readers.add(reader);
        }
        r = new MultiReader((IndexReader[])readers.toArray(new IndexReader[readers.size()]));
        lastMsg = "OK - sharded index (" + readers.size() + " parts)";
      } else {
        parts = 1;
        app.setString(status, "text", "Opening single index ...");
        FsDirectory fsdir =
View Full Code Here

    IndexReader[] subs = new IndexReader[rand.nextInt(nSeg)+1];
    for (int i=0; i<subs.length; i++) {
      subs[i] = dummyIndexReader(rand.nextInt(maxDoc));
    }

    MultiReader mr = new MultiReader(subs);
    return mr;
  }
View Full Code Here

    IndexReader[] subs = new IndexReader[rand.nextInt(nSeg)+1];
    for (int i=0; i<subs.length; i++) {
      subs[i] = dummyIndexReader(rand.nextInt(maxDoc));
    }

    MultiReader mr = new MultiReader(subs);
    return mr;
  }
View Full Code Here

TOP

Related Classes of org.apache.lucene.index.MultiReader

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.