lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Constantin Radchenko" <constantin.radche...@gmail.com>
Subject Re: IndexReader getFieldNames()
Date Wed, 19 Mar 2008 16:42:49 GMT
Try this :

for (Iterator iter = reader.getFieldNames(FieldOption.ALL).iterator();
iter.hasNext();) {
                String fieldName = (String)iter.next();
}

Your code creates iterator each time when you call next()
Also,  if your method  out.print() gets String as parameter, casting is
redundant

Regards

On Wed, Mar 19, 2008 at 6:26 PM, varun sood <vsood2@gmail.com> wrote:

> 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 <serera@gmail.com> 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 <vsood2@gmail.com> 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: java-user-unsubscribe@lucene.apache.org
> > > For additional commands, e-mail: java-user-help@lucene.apache.org
> > >
> > >
> >
> >
> > --
> > Regards,
> >
> > Shai Erera
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
> For additional commands, e-mail: java-user-help@lucene.apache.org
>
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message