Examples of deleteDocuments()


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

      try { oFS.mkdirs(sDirectory); } catch (Exception e) { throw new IOException(e.getClass().getName()+" "+e.getMessage()); }
    } // fi

    IndexReader oReader = IndexReader.open(sDirectory);

    int iDeleted = oReader.deleteDocuments(new Term("guid", sGuid));

    oReader.close();

    return iDeleted;
  } // delete
View Full Code Here

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

  else
  { try 
     { synchronized(this)
       { FSDirectory fsd = FSDirectory.getDirectory(new File(Constants.getINDEXDIR()), false);
         IndexReader ir = IndexReader.open(fsd);
         ir.deleteDocuments(new Term("key", iDocument ) );
         ir.close();
       }
      }
      catch (IOException ie) { logger.error("Failed to delete " + iDocument + " " + ie.getMessage() ); }
     }
View Full Code Here

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

   //*-- clean up the Lucene index
   FSDirectory fsd = FSDirectory.getDirectory(new File(Constants.getINDEXDIR()), false);
   IndexReader ir = IndexReader.open(fsd);
   for (int i = 0; i < delFiles.size(); i++)
    ir.deleteDocuments(new Term("key", (String) delFiles.get(i)) );
   ir.close();
  }
  catch (DatabaseException dbe)
  { logger.error("Could not open cursor to browse File index" + dbe.getMessage() ); }
  catch (UnsupportedEncodingException ue)
View Full Code Here

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

            // Delete all documents with "_hibernate_class" term of the selected entity
            DirectoryProvider dirProvider = ftSession.getSearchFactory().getDirectoryProviders(entityClass)[0];
            IndexReader reader = IndexReader.open(dirProvider.getDirectory());

            // TODO: This is using an internal term of HSearch
            reader.deleteDocuments(new Term("_hibernate_class", entityClass.getName()));
            reader.close();

            // Optimize index
            progress.setStatus("Optimizing index");
            log.debug("optimizing index (merging segments)");
View Full Code Here

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

        // loop over all documents in updateQueue
        for (int i = 0; i < updateCopy.size(); i++) {
          String resourceUrl = updateCopy.get(i).get(OlatDocument.RESOURCEURL_FIELD_NAME);
          Term term = new Term(OlatDocument.RESOURCEURL_FIELD_NAME, resourceUrl );
          log.info("updateQueue:delete documents with resourceUrl=" + resourceUrl );
          indexReader.deleteDocuments(term);         
        }
        // loop over all documents in deleteQueue
        for (int i = 0; i < deleteCopy.size(); i++) {
          String resourceUrl = deleteCopy.get(i).get(OlatDocument.RESOURCEURL_FIELD_NAME);
          Term term = new Term(OlatDocument.RESOURCEURL_FIELD_NAME, resourceUrl );
View Full Code Here

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

        // loop over all documents in deleteQueue
        for (int i = 0; i < deleteCopy.size(); i++) {
          String resourceUrl = deleteCopy.get(i).get(OlatDocument.RESOURCEURL_FIELD_NAME);
          Term term = new Term(OlatDocument.RESOURCEURL_FIELD_NAME, resourceUrl );
          log.info("deleteQueue:delete documents with resourceUrl='" + resourceUrl + "'");
          indexReader.deleteDocuments(term);
         
        }
        log.info("after delete: indexReader.numDocs()=" + indexReader.numDocs());
        // 3. Close reader
        indexReader.close();
View Full Code Here

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

        //--------------------------------------------------------------------

        // deleting the document just added, this will cause a different exception to take place
        Term term = new Term("id", "doc1");
        IndexReader readerB = IndexReader.open(indexStoreB, false);
        readerB.deleteDocuments(term);
        readerB.close();

        // optimizing the index with the writer
        writerB = new IndexWriter(indexStoreB, new StandardAnalyzer(org.apache.lucene.util.Version.LUCENE_CURRENT), false, IndexWriter.MaxFieldLength.LIMITED);
        writerB.optimize();
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.IndexReader.deleteDocuments()

      document.add(new Field("field", "a sample", Field.Store.YES, Field.Index.TOKENIZED));
      document.add(new Field("filter", "a sample filter", Field.Store.YES, Field.Index.TOKENIZED));
      document.add(new Field("sort", "2", Field.Store.YES, Field.Index.UN_TOKENIZED));
      writer.addDocument(document);

      reader.deleteDocuments(new Term("field", "sample"));
   
      fail();
    } catch(IOException ex) {}
  }
View Full Code Here

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

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

      reader.deleteDocuments(new Term("field", "sample"));
      reader.close();
   
      fail();
    } catch(IOException ex) {}
  }
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.