lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Erick Erickson <erickerick...@gmail.com>
Subject Re: How to loop through all the entries for a field
Date Thu, 22 Oct 2009 19:02:24 GMT
Try something like
TermEnum te = IndexReader.terms(new Term("BookTitle", ""));
do {
    Term term = te.term();
    if (! term.field().equals("BookTitle")) break;
    System.out.println(term.text());
} while (te.next());


Note that next() will merrily continue beyond the last term for
the field "BookTitle", so you have to check that you're still
where you want to be.


Best
Erick

On Thu, Oct 22, 2009 at 11:52 AM, adviner <eric.advincula@gmail.com> wrote:

>
> I have a field in called BookTitle.  I want to loop through all the entries
> without doing a search.  I just want to get the list of BookTitle's that is
> in this field:
>
> I tried IndexReader but MaxDocs() doesnt work because it returns everything
> and I have other fields in their which is allot bigger.
>
>
> Sorry i originally posted to the developer site which is wrong place so i
> moved it here
> --
> View this message in context:
> http://www.nabble.com/How-to-loop-through-all-the-entries-for-a-field-tp26012512p26012512.html
> Sent from the Lucene - Java Users mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
> For additional commands, e-mail: java-user-help@lucene.apache.org
>
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message