Package org.apache.lucene.index

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


    assertEquals(air.hasDeletions(), tir.hasDeletions());
    assertEquals(air.maxDoc(), tir.maxDoc());
    assertEquals(air.numDocs(), tir.numDocs());
    assertEquals(air.numDeletedDocs(), tir.numDeletedDocs());

    air.deleteDocument(8);
    tir.deleteDocument(8);

    assertEquals(air.isCurrent(), tir.isCurrent());
    assertEquals(air.hasDeletions(), tir.hasDeletions());
    assertEquals(air.maxDoc(), tir.maxDoc());
View Full Code Here


    /** fetch the compressed string field and compare it's content with the original one */
    String stringFldCompressedTest = docFromReader.get("stringCompressed");
    assertTrue(stringFldCompressedTest.equals(binaryValCompressed));

    /** delete the document from index */
    reader.deleteDocument(0);
    assertEquals(0, reader.numDocs());
   
    reader.close();
    dir.close();
  }
View Full Code Here

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

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

        IndexSearcher searcher = new IndexSearcher(reader);
        ScoreDoc[] hits = searcher.search(new TermQuery(bbb), null, 1000).scoreDocs;
View Full Code Here

      while ( termDocs.next() ) {
        int docIndex = termDocs.doc();
        if ( entityName.equals( reader.document( docIndex ).get( DocumentBuilder.CLASS_FIELDNAME ) ) ) {
          //remove only the one of the right class
          //loop all to remove all the matches (defensive code)
          reader.deleteDocument( docIndex );
        }
      }
    }
    catch (Exception e) {
      throw new SearchException( "Unable to remove from Lucene index: " + entity + "#" + id, e );
View Full Code Here

    testEquals(aprioriIndex,  testIndex);

       // delete a few documents
    IndexReader ir = IndexReader.open(aprioriIndex, false);
    ir.deleteDocument(3);
    ir.deleteDocument(8);
    ir.close();

    ir = testIndex.indexReaderFactory();
    ir.deleteDocument(3);
View Full Code Here

    testEquals(aprioriIndex,  testIndex);

       // delete a few documents
    IndexReader ir = IndexReader.open(aprioriIndex, false);
    ir.deleteDocument(3);
    ir.deleteDocument(8);
    ir.close();

    ir = testIndex.indexReaderFactory();
    ir.deleteDocument(3);
    ir.deleteDocument(8);
View Full Code Here

    ir.deleteDocument(3);
    ir.deleteDocument(8);
    ir.close();

    ir = testIndex.indexReaderFactory();
    ir.deleteDocument(3);
    ir.deleteDocument(8);
    ir.close();

    // make sure they still equal
    testEquals(aprioriIndex,  testIndex);
View Full Code Here

    ir.deleteDocument(8);
    ir.close();

    ir = testIndex.indexReaderFactory();
    ir.deleteDocument(3);
    ir.deleteDocument(8);
    ir.close();

    // make sure they still equal
    testEquals(aprioriIndex,  testIndex);
  }
View Full Code Here

    addDocument(iw, "Hello, earth!");
    addDocument(iw, "All work and no play makes wendy a dull girl");
    iw.close();

    IndexReader multiSegReader = IndexReader.open(dir, false);
    multiSegReader.deleteDocument(2);

    try {
      new InstantiatedIndex(multiSegReader);
    } catch (Exception e) {
      e.printStackTrace(System.out);
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.