You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@lucene.apache.org by Marie-Hélène Forget <mh...@logient.com> on 2003/05/22 16:49:17 UTC
IndexReader.delete(int docNum)
Hi,
I am trying to write a delete method using delete(int docNum) from the
IndexReader class. The problem is that I don't know how to get the
docNum parameter. Can you please help me.
My idea was to perform a search and to delete the documents found. Is
that possible or is there another way around ?
PS: I tried to use delete(Term term), but it did not work. The document
was not deleted.
Thanks for your help:)
MHF
---------------------------------------------------------------------
To unsubscribe, e-mail: lucene-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: lucene-user-help@jakarta.apache.org
Re: IndexReader.delete(int docNum)
Posted by Julien Nioche <Ju...@lingway.com>.
Marie Hélène
in the Hits object the following method gives you the id of the n Document
retrieved
/** Returns the id for the nth document in this set. */
public final int id(int n) throws IOException {
return hitDoc(n).id;
}
you can do your search and delete the docs using thid id number
----- Original Message -----
From: "Guilherme Barile" <gu...@prosoma.com.br>
To: "Lucene Users List" <lu...@jakarta.apache.org>
Sent: Thursday, May 22, 2003 5:06 PM
Subject: Re: IndexReader.delete(int docNum)
> You could list all documents like
>
> IndexReader reader = IndexReader.open(this.indexDir);
> Document doc;
> Vector v;
> for (int i = 0; i < reader.maxDoc(); i++) {
> try {
> doc = reader.document(i);
> v.add(doc.get("somefield"));
> }
> catch (Exception e) {
> System.out.println("Error getting doc " + i);
> }
> }
>
> This way the Vector v would contain all documents, and their index in v
> would be the same as their index in lucene (I'm using this vector to
> populate a JList).
> Read the messages about "query matching all documents", we discussed
> many stuff about this there.
>
> see ya
>
> gui
>
> On Thu, 2003-05-22 at 11:49, Marie-Hélène Forget wrote:
> > Hi,
> >
> > I am trying to write a delete method using delete(int docNum) from the
> > IndexReader class. The problem is that I don't know how to get the
> > docNum parameter. Can you please help me.
> >
> > My idea was to perform a search and to delete the documents found. Is
> > that possible or is there another way around ?
> >
> > PS: I tried to use delete(Term term), but it did not work. The document
> > was not deleted.
> >
> > Thanks for your help:)
> >
> > MHF
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: lucene-user-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: lucene-user-help@jakarta.apache.org
> >
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: lucene-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: lucene-user-help@jakarta.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: lucene-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: lucene-user-help@jakarta.apache.org
Re: IndexReader.delete(int docNum)
Posted by Guilherme Barile <gu...@prosoma.com.br>.
You could list all documents like
IndexReader reader = IndexReader.open(this.indexDir);
Document doc;
Vector v;
for (int i = 0; i < reader.maxDoc(); i++) {
try {
doc = reader.document(i);
v.add(doc.get("somefield"));
}
catch (Exception e) {
System.out.println("Error getting doc " + i);
}
}
This way the Vector v would contain all documents, and their index in v
would be the same as their index in lucene (I'm using this vector to
populate a JList).
Read the messages about "query matching all documents", we discussed
many stuff about this there.
see ya
gui
On Thu, 2003-05-22 at 11:49, Marie-Hélène Forget wrote:
> Hi,
>
> I am trying to write a delete method using delete(int docNum) from the
> IndexReader class. The problem is that I don't know how to get the
> docNum parameter. Can you please help me.
>
> My idea was to perform a search and to delete the documents found. Is
> that possible or is there another way around ?
>
> PS: I tried to use delete(Term term), but it did not work. The document
> was not deleted.
>
> Thanks for your help:)
>
> MHF
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: lucene-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: lucene-user-help@jakarta.apache.org
>
---------------------------------------------------------------------
To unsubscribe, e-mail: lucene-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: lucene-user-help@jakarta.apache.org