Return-Path: Delivered-To: apmail-lucene-java-user-archive@www.apache.org Received: (qmail 30044 invoked from network); 22 Oct 2009 22:43:45 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 22 Oct 2009 22:43:45 -0000 Received: (qmail 83049 invoked by uid 500); 22 Oct 2009 22:43:43 -0000 Delivered-To: apmail-lucene-java-user-archive@lucene.apache.org Received: (qmail 82960 invoked by uid 500); 22 Oct 2009 22:43:43 -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 82950 invoked by uid 99); 22 Oct 2009 22:43:43 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 22 Oct 2009 22:43:43 +0000 X-ASF-Spam-Status: No, hits=-2.6 required=5.0 tests=AWL,BAYES_00 X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of markrmiller@gmail.com designates 209.85.219.226 as permitted sender) Received: from [209.85.219.226] (HELO mail-ew0-f226.google.com) (209.85.219.226) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 22 Oct 2009 22:43:39 +0000 Received: by ewy26 with SMTP id 26so8652461ewy.5 for ; Thu, 22 Oct 2009 15:43:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from :user-agent:mime-version:to:subject:references:in-reply-to :x-enigmail-version:content-type:content-transfer-encoding; bh=neuHwOkyYq5WiQSlx3YtyILRPYg/dQjAnyt37IKe1O4=; b=aau1UB1qSKGMds+fYSGFuxXdOU8b54SpVGLip3pnZy+e+ahNn7Z56Lgo1d1+7joEB+ qVxWv3Si3RcLbR+WkO+i6pwmsrEL68GP4Yb9bHhMVob+EilnmEMkZJC1gwu/An3c7a0z YMWBiY9BuPLVCmZE3ydmD/10WV9GQGQNXwTnw= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:user-agent:mime-version:to:subject:references :in-reply-to:x-enigmail-version:content-type :content-transfer-encoding; b=FcEIUU4i/v9TScr/HNMlfiu/Rbt3q7ubIh/xTRZJQoZF3JoIMJ9g31yBi/T/4L0xsg mEQZdhgecKahJHBqTu5CVfYwJjpc6n6g9rrGe9gZa6bUUjITXrOCAMQ+7VugJ2teo8d+ jcd2IyOKZMhP2P8xqZDgaSKslh+XXaPZbZBbk= Received: by 10.216.89.138 with SMTP id c10mr3661437wef.47.1256251397443; Thu, 22 Oct 2009 15:43:17 -0700 (PDT) Received: from ?192.168.1.108? (ool-44c639d9.dyn.optonline.net [68.198.57.217]) by mx.google.com with ESMTPS id q9sm4004746gve.15.2009.10.22.15.43.15 (version=SSLv3 cipher=RC4-MD5); Thu, 22 Oct 2009 15:43:16 -0700 (PDT) Message-ID: <4AE0E003.3070204@gmail.com> Date: Thu, 22 Oct 2009 18:43:15 -0400 From: Mark Miller User-Agent: Thunderbird 2.0.0.23 (X11/20090817) MIME-Version: 1.0 To: java-user@lucene.apache.org Subject: Re: How to loop through all the entries for a field References: <26012512.post@talk.nabble.com> <359a92830910221202h4fe030efrdabc3d469659067c@mail.gmail.com> <26017418.post@talk.nabble.com> <26017581.post@talk.nabble.com> In-Reply-To: <26017581.post@talk.nabble.com> X-Enigmail-Version: 0.96.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit But with Lucene 2.9 you would want to use StringHelper.intern right? adviner wrote: > Thank you > > > Uwe Schindler wrote: > >> 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 >>> >> >> >> >> >> > > -- - Mark http://www.lucidimagination.com --------------------------------------------------------------------- To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org For additional commands, e-mail: java-user-help@lucene.apache.org