lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Otis Gospodnetic <otis_gospodne...@yahoo.com>
Subject Re: Deleting document from index
Date Sat, 22 Jun 2002 13:31:11 GMT
Hello,

First of all, the machine from which you sent this email has the date
set incorrectly - it thinks it's 22. 6. 2000.

--- amitb@sansuisoftware.com wrote:

> I had searched the archive of this list for getting more info on "How
> to delete a document from the lucene index".
> But most of the postings talk about IndexReader.delete(docNum). When
> we tried to delete a single document entry from the index , what we
> found is : the whole index got deleted. 

You must be doing something wrong.  Send the relevant piece of code.

> 1) Can anyone help us on how we can handle this ?

http://www.jguru.com/faq/view.jsp?EID=492423


    public int delete(final String fieldName, final String fieldValue)
        throws IOException
    {
        final IndexReader reader = IndexReader.open(mIndexDir);
        final int deleteCount    = reader.delete(new Term(fieldName,
fieldValue));
        reader.close();
        return deleteCount;
    }

> 2) When the search results will reflect that, the particular document
> which I had deleted ,is not there ?
> Do I need to "optimize" the index for this ?

You don't need to optimize the index, but I believe you need to close
the IndexReader and re-open IndexSearcher when you detect that the
index has changed.

> 3) After adding few more documents to an existing index, what effect
> will it have on search , if I don't optimize
> the index immediately ? Will these new documents will be searchable
> before optimization ?

Yes.

Otis


__________________________________________________
Do You Yahoo!?
Yahoo! - Official partner of 2002 FIFA World Cup
http://fifaworldcup.yahoo.com

--
To unsubscribe, e-mail:   <mailto:lucene-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:lucene-user-help@jakarta.apache.org>


Mime
View raw message