lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Phil Whelan <phil...@gmail.com>
Subject Enumerating NumericField using TermEnum?
Date Fri, 11 Sep 2009 22:00:49 GMT
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@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org


Mime
View raw message