Hi Harini,

Close the reader after delete docs to take effect.

Hope this helps,

Koji

> -----Original Message-----
> From: Harini Raghavan [mailto:[EMAIL PROTECTED]
> Sent: Monday, January 09, 2006 1:09 AM
> To: java-user@lucene.apache.org
> Subject: Deleting a Document
> 
> 
> Hi,
> I want to update a document in the lucene index. As mentioned in the 
> documentation, I tried to delete the document using IndexReader.delete 
> method. But even after I delete the document, I am able to see the 
> document when I perform a search. I thought this could be because, I am 
> caching the IndexSearcher instance and refreshing it only when required. 
> So I tried to refresh the IndexSearcher instance immediately after 
> deletion. But even this did not solve the problem. Here is the code:
>     public synchronized void deleteDocument(String id) {
>         String indexLoc = luceneConfig.getIndexDir();
>         Directory fsDir = getIndexDirectory(indexLoc, false);
>         IndexReader reader = getIndexReader(fsDir);
>         try {
>             Term t = new Term(IndexSearchConstants.DOCUMENT_ID, id);
>             reader.delete(t);
> 
>             //After deleting the document refresh the 
> IndexSearcher instance
>             manager.refreshIndexSearcher();
>         } catch (IOException e) {
>             logger.error("IOException occurred in deleteDocument()", e);
>         } finally {
>             try {
>                 reader.close();
>             } catch(IOException e) {}
>         }
>     }
> The document seems to be deleted only when I restart the server. Am I 
> missing something while deleting the document? When does the document 
> actually get deleted from the index?
> Thanks,
> Harini
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to