Perfect! Many thanks.
Erik
On Monday, December 30, 2002, at 12:54 PM, Doug Cutting wrote:
Erik Hatcher wrote:
Is it possible for me to retrieve all the values of a particular
field that exists within an index, across all documents?
For example, I'm indexing documents that have a "category" associated
with them. Several documents will share the same category. I'd like
to be able to retrieve all categories.
The trick is to enumerate terms with that field. Terms are sorted
first by field, then by text, so all terms with a given field are
adjacent in enumerations. Term enumeration is also efficient.
try {
TermEnum terms = indexReader.terms(new Term("category", ""));
while ("category".equals(enum.term().field())) {
... collect enum.term().text() ...
if (!terms.next())
break;
}
} finally {
terms.close();
}
Doug
--
To unsubscribe, e-mail:
<mailto:[EMAIL PROTECTED]>
For additional commands, e-mail:
<mailto:[EMAIL PROTECTED]>
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>