I think you're looking for IndexReader.terms(new Term(ArtistIndexField.ARTIST_ID.getName(), ""));
NOTE: the empty string is important. You're effectively positioning your TermEnum at the first term in the index. This works in your case without much checking since there is exactly one document in the index. Take a bit of care that the Term you get back has the field equal to the one you care about (ArtistIndexField.ARTIST_ID.getName()) since termenums will merrily carry on to the next field..... This bit of the JavaDocs is easily overlooked: " If the given term does not exist, the enumeration is positioned at the first term greater than the supplied term." which, if there were no terms for the indicated field would be the *next* field..... HTH Erick On Wed, Jan 6, 2010 at 5:21 AM, Paul Taylor <paul_t...@fastmail.fm> wrote: > Simon Willnauer wrote: > >> Would indexReader#termDocs() help? You get all docs containing a >> specific term - that way you could iterate in reverse order though. >> >> simon >> > > Thanks, almost if I do this I can determine that a document exists with a > term with a particular value works > > TermDocs termDocs = ir.termDocs(new > Term(ArtistIndexField.ARTIST_ID.getName(),"4302e264-1cf0-4d1f-aca7-2a6f89e34b36")); > termDocs.next(); > assertEquals(1,termDocs.freq()); > > but this doesnt work > > TermDocs termDocs = ir.termDocs(new > Term(ArtistIndexField.ARTIST_ID.getName())); > termDocs.next(); > assertEquals(1,termDocs.freq()); > > which is what I really want, i.e that document has a term for this > fieldname > > (In any test there is only ever one document) > > > Paul > > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: java-user-unsubscr...@lucene.apache.org > For additional commands, e-mail: java-user-h...@lucene.apache.org > >