Package org.apache.lucene.index

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


        IndexReader reader = IndexReader.open(dir);
        Term aaa = new Term("content", "aaa");
        Term bbb = new Term("content", "bbb");
        Term ccc = new Term("content", "ccc");
        assertEquals(reader.docFreq(ccc), 37);
        reader.deleteDocument(0);
        assertEquals(reader.docFreq(aaa), 37);
        dir.tweakBufferSizes();
        reader.deleteDocument(4);
        assertEquals(reader.docFreq(bbb), 37);
        dir.tweakBufferSizes();
View Full Code Here


        Term ccc = new Term("content", "ccc");
        assertEquals(reader.docFreq(ccc), 37);
        reader.deleteDocument(0);
        assertEquals(reader.docFreq(aaa), 37);
        dir.tweakBufferSizes();
        reader.deleteDocument(4);
        assertEquals(reader.docFreq(bbb), 37);
        dir.tweakBufferSizes();

        IndexSearcher searcher = new IndexSearcher(reader);
        Hits hits = searcher.search(new TermQuery(bbb));
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

        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(), false);
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

    Hits hits = searcher.search(q);
    log("Got "+hits.length()+" results");
    assertEquals("must match all "+N+" docs, not only "+hits.length()+" docs!",N,hits.length());
    if (deleteInFront) {
      log("deleting hits that was not yet retrieved!");
      reader.deleteDocument(reader.maxDoc()-1);
      reader.deleteDocument(reader.maxDoc()-2);
      reader.deleteDocument(reader.maxDoc()-3);
    }
    try {
      for (int i = 0; i < hits.length(); i++) {
View Full Code Here

    log("Got "+hits.length()+" results");
    assertEquals("must match all "+N+" docs, not only "+hits.length()+" docs!",N,hits.length());
    if (deleteInFront) {
      log("deleting hits that was not yet retrieved!");
      reader.deleteDocument(reader.maxDoc()-1);
      reader.deleteDocument(reader.maxDoc()-2);
      reader.deleteDocument(reader.maxDoc()-3);
    }
    try {
      for (int i = 0; i < hits.length(); i++) {
        int id = hits.id(i);
View Full Code Here

    assertEquals("must match all "+N+" docs, not only "+hits.length()+" docs!",N,hits.length());
    if (deleteInFront) {
      log("deleting hits that was not yet retrieved!");
      reader.deleteDocument(reader.maxDoc()-1);
      reader.deleteDocument(reader.maxDoc()-2);
      reader.deleteDocument(reader.maxDoc()-3);
    }
    try {
      for (int i = 0; i < hits.length(); i++) {
        int id = hits.id(i);
        assertEquals("Hit "+i+" has doc id "+hits.id(i)+" instead of "+i,i,hits.id(i));
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.