opensubscriber
   Find in this group all groups
 
Unknown more information…

j : java-user@lucene.apache.org 12 September 2009 • 6:00AM -0400

Enumerating NumericField using TermEnum?
by Phil Whelan

REPLY TO AUTHOR
 
REPLY TO GROUP




Hi,

I've used NumericField to store my "hour" field.

Example...

     doc.add(new NumericField("hour").setIntValue(Integer.parseInt("12")));

Before I was using plain string Field and enumerating them with
TermEnum, which worked fine.
Now I'm using NumericField's I'm not sure how to port this enumeration code.

Any pointers?

This is the code I was using previously for plain Fields.

    ArrayList hours = new ArrayList();
    TermEnum termEnum = reader.terms( new Term( "hour", "" ) );
    Term term = null;
    while ( ( term = termEnum.term() ) != null ) {

        if ( ! term.field().equals( "hour" ) )
            break;

        hours.add( (Integer)term.text() );
        termEnum.next();
    }

Thanks,
Phil

---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@luce...
For additional commands, e-mail: java-user-help@luce...

Bookmark with:

Delicious   Digg   reddit   Facebook   StumbleUpon

Related Messages

opensubscriber is not affiliated with the authors of this message nor responsible for its content.