Package org.apache.lucene.index

Examples of org.apache.lucene.index.IndexReader.deleteDocument()


    assertEquals(3, reader.numDocs());
    reader.close();

    reader = IndexReader.open(aux2);
    for (int i = 0; i < 8; i++) {
      reader.deleteDocument(i);
    }
    assertEquals(22, reader.numDocs());
    reader.close();

    writer = newWriter(dir, false);
View Full Code Here


    IndexReader reader = IndexReader.open(new FsDirectory(fs, index, false, getConf()), false);
    try {
      while (values.hasNext()) {
        IntWritable value = values.next();
        LOG.debug("-delete " + index + " doc=" + value);
        reader.deleteDocument(value.get());
      }
    } finally {
      reader.close();
    }
  }
View Full Code Here

      int readerMax = reader.maxDoc();
      for (int doc = 0; doc < readerMax; doc++) {
        if (!reader.isDeleted(doc)) {
          Document document = reader.document(doc);
          if (document.get(CCIndexingFilter.FIELD)==null){ // no CC fields
            reader.deleteDocument(doc);                    // delete it
            deleteCount++;
          }
        }
      }
    }
View Full Code Here

    setUpDirs(dir, aux);

    IndexReader reader = IndexReader.open(aux);
    for (int i = 0; i < 20; i++) {
      reader.deleteDocument(i);
    }
    assertEquals(10, reader.numDocs());
    reader.close();

    IndexWriter writer = newWriter(dir, false);
View Full Code Here

    assertEquals(3, writer.getSegmentCount());
    writer.close();

    IndexReader reader = IndexReader.open(aux);
    for (int i = 0; i < 27; i++) {
      reader.deleteDocument(i);
    }
    assertEquals(3, reader.numDocs());
    reader.close();

    reader = IndexReader.open(aux2);
View Full Code Here

    assertEquals(3, reader.numDocs());
    reader.close();

    reader = IndexReader.open(aux2);
    for (int i = 0; i < 8; i++) {
      reader.deleteDocument(i);
    }
    assertEquals(22, reader.numDocs());
    reader.close();

    writer = newWriter(dir, false);
View Full Code Here

            while (termDocs.next()) {
                /*
                 * if this is a pure delete just delete it an continue
                 */
                if (docToKeep == 0) {
                    reader.deleteDocument(termDocs.doc());
                    continue;
                }

                int prev = this.documentNumber[pos];
                this.documentNumber[pos] = termDocs.doc();
View Full Code Here

                }

                int prev = this.documentNumber[pos];
                this.documentNumber[pos] = termDocs.doc();
                if (prev != -1) {
                    reader.deleteDocument(prev);
                }

                if (++pos >= docToKeep)
                    pos = 0;
View Full Code Here

    /** fetch the compressed string field and compare it's content with the original one */
    String stringFldCompressedTest = new String(docFromReader.get("stringCompressed"));
    assertTrue(stringFldCompressedTest.equals(binaryValCompressed));
   
    /** delete the document from index */
    reader.deleteDocument(0);
    assertEquals(0, reader.numDocs());
   
    reader.close();
   
  }
View Full Code Here

        writer.close();

        // delete 40 documents
        reader = IndexReader.open(dir);
        for (i = 0; i < 40; i++) {
            reader.deleteDocument(i);
        }
        reader.close();

        // test doc count before segments are merged/index is optimized
        writer = new IndexWriter(dir, new WhitespaceAnalyzer());
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.