lucene-solr-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Chris Hostetter <hossman_luc...@fucit.org>
Subject RE: How to read values of a field efficiently
Date Mon, 20 Aug 2007 18:41:46 GMT
: > TermEnum terms = searcher.getReader().terms(new Term(field, ""));
: > 	while (terms.term() != null && terms.term().field() == field){
: > 		//do things
: > 		terms.next();
: > 	}

:     while( te.next() ) {
:         final Term term = te.term();


you're missing the key piece that Ard alluded to ... the there is one
ordere list of all terms stored in the index ... a TermEnum lets you
iterate over this ordered list, and the IndexReader.terms(Term) method
lets you efficiently start at an arbitrary term.  if you are only
interested in terms for a specific field, once your TermEnum returns a
differnet field, you can stop -- you will never get any more terms for
the field you care about (hence Ard's terms.term().field() == field in his
loop conditional)


-Hoss


Mime
View raw message