: Is there a simple way to list all terms in a field? : The only approach that I see is to use the IndexReader.terms() method : and then iterate over all the results and build my list by manually : filtering. This seems inefficient and there must be a better way that : my newbie eyes don't see.
it's the most efficient way i can think of, the trick is in the specifics of the documentation: 1) TermEnum says... Term enumerations are always ordered by Term.compareTo(). Each term in the enumeration is greater than all that precede it. 2) Term.compareTo(Term) says... The ordering of terms is first by field, then by text. 2) IndexReader.terms(Term) says... Returns an enumeration of all terms after a given term. ...which means that if you want all of the Terms for a given field, you can call IntexReader.terms(new Term("field","")) and get a TermEnum starting at the very first Term in that field. you cna then iterate over the Terms untill you encounter one for a different field (or hit the end of the TermEnum) I think that's about as efficient as it gets. take a look at RangeFilter for an example in use... http://svn.apache.org/viewcvs.cgi/lucene/java/trunk/src/java/org/apache/lucene/search/RangeFilter.java -Hoss --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]