Examples of deleteDocuments()


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

    document.add(new Field("sort", "2", Field.Store.YES, Field.Index.UN_TOKENIZED));
    writer.addDocument(document);
    writer.close();

    IndexReader reader = IndexReader.open(directory);
    reader.deleteDocuments(new Term("field", "sample"));
    reader.close();
  }

  public void testAddOptimizeDocument() throws Exception {
    IndexWriter writer = new IndexWriter(directory, new SimpleAnalyzer(), false);
View Full Code Here

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

  public void testDeleteOptimizeDocumentError1() throws Exception {
    try {
      IndexWriter writer = new IndexWriter(directory, new SimpleAnalyzer(), false);
      IndexReader reader = IndexReader.open(directory);
      reader.deleteDocuments(new Term("field", "sample"));
      writer.optimize();
     
      fail();
    } catch (Exception ex) { }
  }
View Full Code Here

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

  public void testDeleteOptimizeDocumentError2() throws Exception {
    try {
      IndexWriter writer = new IndexWriter(directory, new SimpleAnalyzer(), false);
      IndexReader reader = IndexReader.open(directory);
      reader.deleteDocuments(new Term("field", "sample"));
      reader.close();
      writer.optimize();
      writer.close();
     
      fail();
View Full Code Here

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

    } catch (Exception ex) { }
  }

  public void testDeleteOptimizeDocumentSucess() throws Exception {
    IndexReader reader = IndexReader.open(directory);
    reader.deleteDocuments(new Term("field", "sample"));
    reader.close();

    IndexWriter writer = new IndexWriter(directory, new SimpleAnalyzer(), false);
    writer.optimize();
    writer.close();
View Full Code Here

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

    // remove deleted documents
    IndexReader indexDeleter = index.indexReaderFactory();
    if (unflushedDeletions.size() > 0) {
      for (Term term : unflushedDeletions) {
        indexDeleter.deleteDocuments(term);
      }
      unflushedDeletions.clear();
    }

View Full Code Here

Examples of org.apache.lucene.index.IndexWriter.deleteDocuments()

    writer.close();
  }
 
  private void deleteDocument() throws IOException {
    IndexWriter writer = new IndexWriter(dir, new IndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(random, MockTokenizer.WHITESPACE, false)).setOpenMode(OpenMode.APPEND));
    writer.deleteDocuments( new Term( "t_text1", "del" ) );
    // To see negative idf, keep comment the following line
    //writer.optimize();
    writer.close();
  }
 
View Full Code Here

Examples of org.apache.lucene.index.IndexWriter.deleteDocuments()

                                      MaxFieldLength.LIMITED);
      for (int i = 0; i < numDeletedDocs; i++) {
        w.addDocument(new Document());
      }
      w.commit();
      w.deleteDocuments( new MatchAllDocsQuery() );
      w.commit();

      if (0 < numDeletedDocs)
        Assert.assertTrue("writer has no deletions", w.hasDeletions());
View Full Code Here

Examples of org.apache.lucene.index.IndexWriter.deleteDocuments()

    ConstantScoreQuery constantScore = new ConstantScoreQuery(filter);
    docs = searcher.search(constantScore, 1);
    assertEquals("[just filter] Should find a hit...", 1, docs.totalHits);

    // now delete the doc, refresh the reader, and see that it's not there
    writer.deleteDocuments(new Term("id", "1"));

    reader = refreshReader(reader);
    searcher = new IndexSearcher(reader);

    docs = searcher.search(new MatchAllDocsQuery(), filter, 1);
View Full Code Here

Examples of org.apache.lucene.index.IndexWriter.deleteDocuments()

    docs = searcher.search(constantScore, 1);
    assertEquals("[just filter] Should find a hit...", 1, docs.totalHits);
    assertEquals(missCount, filter.missCount);

    // now delete the doc, refresh the reader, and see that it's not there
    writer.deleteDocuments(new Term("id", "1"));

    reader = refreshReader(reader);
    searcher = new IndexSearcher(reader);

    missCount = filter.missCount;
View Full Code Here

Examples of org.apache.lucene.index.IndexWriter.deleteDocuments()

    constantScore = new ConstantScoreQuery(filter);
    docs = searcher.search(constantScore, 1);
    assertEquals("[just filter] Should find a hit...", 1, docs.totalHits);

    // now delete the doc, refresh the reader, and see that it's not there
    writer.deleteDocuments(new Term("id", "1"));

    reader = refreshReader(reader);
    searcher = new IndexSearcher(reader);

    docs = searcher.search(new MatchAllDocsQuery(), filter, 1);
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.