Return-Path: Delivered-To: apmail-lucene-java-user-archive@www.apache.org Received: (qmail 7878 invoked from network); 22 Oct 2009 21:29:31 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 22 Oct 2009 21:29:31 -0000 Received: (qmail 87241 invoked by uid 500); 22 Oct 2009 21:29:29 -0000 Delivered-To: apmail-lucene-java-user-archive@lucene.apache.org Received: (qmail 87151 invoked by uid 500); 22 Oct 2009 21:29:29 -0000 Mailing-List: contact java-user-help@lucene.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: java-user@lucene.apache.org Delivered-To: mailing list java-user@lucene.apache.org Received: (qmail 87141 invoked by uid 99); 22 Oct 2009 21:29:29 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 22 Oct 2009 21:29:29 +0000 X-ASF-Spam-Status: No, hits=3.4 required=10.0 tests=HTML_MESSAGE,SPF_NEUTRAL X-Spam-Check-By: apache.org Received-SPF: neutral (nike.apache.org: local policy) Received: from [85.25.71.29] (HELO mail.troja.net) (85.25.71.29) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 22 Oct 2009 21:29:17 +0000 Received: from localhost (localhost.localdomain [127.0.0.1]) by mail.troja.net (Postfix) with ESMTP id 3196AD36008 for ; Thu, 22 Oct 2009 23:28:57 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at mail.troja.net Received: from mail.troja.net ([127.0.0.1]) by localhost (megaira.troja.net [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 6t9G+rK4xkLx for ; Thu, 22 Oct 2009 23:28:46 +0200 (CEST) Received: from VEGA (port-83-236-62-3.dynamic.qsc.de [83.236.62.3]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.troja.net (Postfix) with ESMTPSA id 61227D36006 for ; Thu, 22 Oct 2009 23:28:46 +0200 (CEST) From: "Uwe Schindler" To: References: <26012512.post@talk.nabble.com> <359a92830910221202h4fe030efrdabc3d469659067c@mail.gmail.com> <26017418.post@talk.nabble.com> Subject: RE: How to loop through all the entries for a field Date: Thu, 22 Oct 2009 23:28:47 +0200 Message-ID: MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_NextPart_000_0000_01CA536F.67AFCC10" X-Mailer: Microsoft Office Outlook 11 In-Reply-To: <26017418.post@talk.nabble.com> Thread-Index: AcpTXZRifbPz4LrTQSupqzXg63nxxAAAKzrg X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.5579 X-Virus-Checked: Checked by ClamAV on apache.org ------=_NextPart_000_0000_01CA536F.67AFCC10 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Use this one: String fieldname="BookTitle"; fieldname = fieldname.intern(); // because of this we need no String.equals() TermEnum te = IndexReader.terms(new Term(fieldname, "")); do { Term term = te.term(); if (term == null || term.field() != fieldname) break; System.out.println(term.text()); } while (te.next()); te.close(); ----- Uwe Schindler H.-H.-Meier-Allee 63, D-28213 Bremen http://www.thetaphi.de eMail: uwe@thetaphi.de > -----Original Message----- > From: adviner [mailto:eric.advincula@gmail.com] > Sent: Thursday, October 22, 2009 11:20 PM > To: java-user@lucene.apache.org > Subject: Re: How to loop through all the entries for a field > > > How do you know if your on your last term? I tried it and it does work > but > continues. How do you know to check if its the last entry? > > Thanks > > > Erick Erickson wrote: > > > > 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 > > 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 > >> > >> > > > > > > -- > View this message in context: http://www.nabble.com/How-to-loop-through- > all-the-entries-for-a-field-tp26012512p26017418.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 ------=_NextPart_000_0000_01CA536F.67AFCC10--