Package org.apache.lucene.index

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


    IndexReader reader = IndexReader.open(new FsDirectory(fs, index, false, getConf()));
    try {
      while (values.hasNext()) {
        IntWritable value = (IntWritable)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

        }
      }
            //Now we have all lucene's ids of documents to be deleted and we can
            //proceed with the actual deletion.
            for (Integer i : documentsToDelete) {
                reader.deleteDocument(i);
            }
           
    } catch (IOException e) {
      logger.fatal("applyDeletes: IOException caught.", e);
            throw new RuntimeException(e);
View Full Code Here

                                    if (! realFileModDate.equals(curFiModDate)) {
                                        logger.info("updateIndex() updating " + curFiName + " in index");

                                        numUpdates++;
                                        // remove old document
                                        ir.deleteDocument(i);
                                        ir.close();
                                        // open writer to add document once again
                                        ds.setStatus("Reindexing: " + curFiName);
                                        IndexWriter iw = new IndexWriter(di.getIndexPath(), new StandardAnalyzer(), false);
                                        // next line should remove too many files open errors
View Full Code Here

                                    }
                                }
                                else {
                                    ds.setStatus("Deleting: " + curFiName);
                                    logger.info("updateIndex() remove " + curFiName + " from index");
                                    ir.deleteDocument(i);
                                    addDelNote(doc);
                                    numRemovals++;
                                }
                            }
                        }
View Full Code Here

          readerForDelete = openIndexReaderForDelete();
          if (readerForDelete!=null)
          {
            for (int docid : delArray)
            {
              readerForDelete.deleteDocument(docid);
            }
          }
        }
        finally
        {
View Full Code Here

    IndexReader reader = IndexReader.open(new FsDirectory(fs, index, false, getConf()));
    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

        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

    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

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.