lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Julien Nioche" <Julien.Nio...@lingway.com>
Subject Re: IndexReader.delete(int docNum)
Date Thu, 22 May 2003 15:23:44 GMT
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" <gui@prosoma.com.br>
To: "Lucene Users List" <lucene-user@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


Mime
View raw message