You are asking for a new iterator each time around the loop - you'll just be 
printing the first field forever.....

----- Original Message ----
From: varun sood <[EMAIL PROTECTED]>
To: java-user@lucene.apache.org
Sent: Wednesday, 19 March, 2008 4:26:39 PM
Subject: Re: IndexReader getFieldNames()

Hi Shai,
 The code I pasted is not working.. sorry abt that..
 The code which is working is ..

 Collection c = ir.getFieldNames(IndexReader.FieldOption.ALL);
 int i = 0;
 while (c.iterator().hasNext()) {
    out.print(c.iterator().next(););
    i++;
 }

This hangs my machine for minutes minutes on my dual core to optuput
the result.
I am doing sth wrong.
"I mean I do not know where the field names are stored.. " in the enum
and how to get them.
Perhaps its a trivial thing for a person who has used indexReader to
list all the fields in the index.

On Wed, Mar 19, 2008 at 9:20 AM, Shai Erera <[EMAIL PROTECTED]> wrote:
> Can you give an example of the output?
> What does out.print() do? Does it print spaces between records on new-lines?
>
>
> On Wed, Mar 19, 2008 at 3:17 PM, varun sood <[EMAIL PROTECTED]> wrote:
>
> > Hi All,
> >  Can someone please guide me on how to use IndexReader's
> > getFieldNames() method properly?
> > I want to get all the filed names in the index. Currently I am getitng
> > it via Document object but that not wt i want.
> > I am implementing the code below and what I get is a very long string
> > of characters.. perhaps equivalent to the number of records in the
> > index.
> >
> > Collection c = ir.getFieldNames(IndexReader.FieldOption.ALL);
> > int i = 0;
> > while (c.iterator().hasNext()) {
> >    Field s = (Field) c.iterator().next();
> >    out.print(s.name());
> >    i++;
> > }
> >
> > Thanks,
> > Varun.
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > For additional commands, e-mail: [EMAIL PROTECTED]
> >
> >
>
>
> --
> Regards,
>
> Shai Erera
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]






      ___________________________________________________________ 
Rise to the challenge for Sport Relief with Yahoo! For Good  

http://uk.promotions.yahoo.com/forgood/

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to