lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Derya Kasapoglu" <doz...@gmx.de>
Subject RE: UpdateIndex
Date Mon, 29 Aug 2005 15:00:56 GMT
Thank you for your help!
But it doesn't work that way!!

My code is: 

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();

So... but it doesn't delete the documents by the first start!
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 in first run
for example only 12 of 20 documents (it's different)!!

> --- Ursprüngliche Nachricht ---
> Von: "Mordo, Aviran (EXP N-NANNATEK)" <aviran.mordo@lmco.com>
> An: java-user@lucene.apache.org
> Betreff: RE: UpdateIndex
> Datum: Mon, 29 Aug 2005 10:30:18 -0400
> 
> No, just at the end of the delete loop get a new reader instance.
> 
> Aviran
> http://www.aviransplace.com 
> 
> 
> -----Original Message-----
> From: dozean@gmx.de [mailto:dozean@gmx.de] 
> Sent: Monday, August 29, 2005 10:10 AM
> To: java-user@lucene.apache.org
> Subject: RE: UpdateIndex
> 
> for (int i=0; i<reader.numDocs(); i++) {
>   Document doc =reader.document(i);
>   String path = doc.get("path");
>   File file = new File(path);
>   long dl = Long.parseLong(doc.get("date"));
>   long fl = new File(path).lastModified();
> 
> if (!file.exists()) {reader.delete(i);}
> 
> }
> 
> i need a new IndexReader for each i?
> 
> 
> > --- Ursprüngliche Nachricht ---
> > Von: "Mordo, Aviran (EXP N-NANNATEK)" <aviran.mordo@lmco.com>
> > An: java-user@lucene.apache.org
> > Betreff: RE: UpdateIndex
> > Datum: Mon, 29 Aug 2005 09:28:59 -0400
> > 
> > After you delete / add documents, you need to get a new IndexReader 
> > instance to reflect the changes.
> > 
> > HTH
> > 
> > Aviran
> > http://www.aviransplace.com
> > 
> > -----Original Message-----
> > From: dozean@gmx.de [mailto:dozean@gmx.de]
> > Sent: Monday, August 29, 2005 7:32 AM
> > To: java-user@lucene.apache.org
> > Subject: Re: UpdateIndex
> > 
> > Hi,
> > 
> > over again a question about updating!
> > I update my index by first deletion all the documents from index which 
> > are not anymore in the document directories, then i delete all 
> > documents >from index which have changed and at last i add all 
> > documents to the index which are not in the index but in the document
> directories!!!
> > But i is like that... that all works very good!
> > But the problem is that it doesn't find all documents to add or delete 
> > by the first running!!! For example i deleted 12 documents from the 
> > directory or i changed them. If i start the application it delete only 
> > 7 >from
> index.
> > If i start the application again it delete the other rest!!! But why?
> > 
> > Why doesn't do it by the first time!!!?
> > 
> > Thanks in forward!
> > Bye
> > 
> > --
> > Lust, ein paar Euro nebenbei zu verdienen? Ohne Kosten, ohne Risiko!
> > Satte Provisionen für GMX Partner: http://www.gmx.net/de/go/partner
> > 
> > ---------------------------------------------------------------------
> > 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
> > 
> 
> --
> Lust, ein paar Euro nebenbei zu verdienen? Ohne Kosten, ohne Risiko!
> Satte Provisionen für GMX Partner: http://www.gmx.net/de/go/partner
> 
> ---------------------------------------------------------------------
> 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
> 

-- 
Lust, ein paar Euro nebenbei zu verdienen? Ohne Kosten, ohne Risiko!
Satte Provisionen für GMX Partner: http://www.gmx.net/de/go/partner

---------------------------------------------------------------------
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