lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Yonik Seeley <ysee...@gmail.com>
Subject Re: IndexReader delete(int i)
Date Mon, 29 Aug 2005 19:55:26 GMT
Perhaps because you are not iterating over all the documents?
numDocs() == maxDocs() - numer_of_deleted_docs
So first try replacing numDocs() with maxDocs()

-Yonik


On 8/29/05, Derya Kasapoglu <dozean@gmx.de> wrote:
> Hi,
> 
> if i delete a document from index, what does the it do?
> I want to know because if i delete documents from index which are
> not anymore in the dokument directories like that:
> 
> IndexReader reader = IndexReader.open(dir);
> 
> for (int i=0; i<reader.numDocs(); i++) {
> 
>         Document doc =reader.document(i);
>         String path = doc.get("path");
>         File file = new File(path);
> 
>         if (!file.exists()) reader.delete(i);
> }
> 
> reader.close();
> 
> the IndexReader doesn't delete all dokuments by the first run!!!!
> 
> I mean if i say
> if (!file.exists()) System.out.println(path);
> i get all documents which are not in the directory  but if i say reader.delete(i)
> it deletes only a part of the documents which are not exists!!!
> If i start the application again it delets the rest, sometimes not all of the rest,
> but if i start it again and again it deletes all documents which are not exists.
> 
> But why it doen't do it by the first run?
> Does delete() do something  with the document IDs? Or something else?
> 
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
> For additional commands, e-mail: java-user-help@lucene.apache.org
> 
>

---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org


Mime
View raw message