Package org.apache.lucene.index

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


        assertEquals("Hit "+i+" has doc id "+hits.id(i)+" instead of "+i,i,hits.id(i));
        if ((intermittent && (i==50 || i==250 || i==950)) || //100-yes, 200-no, 400-yes, 800-no, 1600-yes
            (!intermittent && (k<2 || (i>0 && i%k==0)))) {
          Document doc = hits.doc(id);
          log("Deleting hit "+i+" - doc "+doc+" with id "+id);
          reader.deleteDocument(id);
        }
        if (intermittent) {
          // check internal behavior of Hits (go 50 ahead of getMoreDocs points because the deletions cause to use more of the available hits)
          if (i==150 || i==450 || i==1650) {
            assertTrue("Hit "+i+": hits should have checked for deletions in last call to getMoreDocs()",hits.debugCheckedForDeletions);
View Full Code Here


        //
        int pos=0;
        while (tdocs.next()) {
          if (saveLast==0) {
            // special case - delete all the docs as we see them.
            reader.deleteDocument(tdocs.doc());
            numDeletes++;
            continue;
          }

          int prev=docnums[pos];
View Full Code Here

          }

          int prev=docnums[pos];
          docnums[pos]=tdocs.doc();
          if (prev != -1) {
            reader.deleteDocument(prev);
            numDeletes++;
          }

          if (++pos >= saveLast) pos=0;
        }
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();
   
  }
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

        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

      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

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.