Package org.apache.lucene.index

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


      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


    throws IOException {
    Path index = new Path(key.toString());
    IndexReader reader = IndexReader.open(new FsDirectory(fs, index, false, getConf()));
    try {
      while (values.hasNext()) {
        reader.deleteDocument(((IntWritable)values.next()).get());
      }
    } finally {
      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

        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

    testEquals(aprioriIndex,  testIndex);

       // delete a few documents
    IndexReader ir = IndexReader.open(aprioriIndex);
    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);
    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

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.