Return-Path: Delivered-To: apmail-lucene-java-user-archive@www.apache.org Received: (qmail 89144 invoked from network); 7 Mar 2008 12:11:23 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 7 Mar 2008 12:11:23 -0000 Received: (qmail 29015 invoked by uid 500); 7 Mar 2008 12:11:13 -0000 Delivered-To: apmail-lucene-java-user-archive@lucene.apache.org Received: (qmail 28989 invoked by uid 500); 7 Mar 2008 12:11:13 -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 28978 invoked by uid 99); 7 Mar 2008 12:11:13 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 07 Mar 2008 04:11:13 -0800 X-ASF-Spam-Status: No, hits=1.2 required=10.0 tests=SPF_NEUTRAL X-Spam-Check-By: apache.org Received-SPF: neutral (athena.apache.org: local policy) Received: from [208.97.132.177] (HELO spunkymail-a11.g.dreamhost.com) (208.97.132.177) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 07 Mar 2008 12:10:34 +0000 Received: from [192.168.0.3] (adsl-074-229-189-244.sip.rmo.bellsouth.net [74.229.189.244]) by spunkymail-a11.g.dreamhost.com (Postfix) with ESMTP id 8168DB89C1 for ; Fri, 7 Mar 2008 04:10:39 -0800 (PST) Message-Id: From: Grant Ingersoll To: java-user@lucene.apache.org In-Reply-To: Content-Type: text/plain; charset=US-ASCII; format=flowed; delsp=yes Content-Transfer-Encoding: 7bit Mime-Version: 1.0 (Apple Message framework v919.2) Subject: Re: Hits. Date: Fri, 7 Mar 2008 07:10:37 -0500 References: X-Mailer: Apple Mail (2.919.2) X-Virus-Checked: Checked by ClamAV on apache.org You sure can. Or you can use the SetBasedFieldSelector that already exists in o.a.lucene.document. -Grant On Mar 7, 2008, at 5:26 AM, Sergey Kabashnyuk wrote: > Hi. > I have a question about retrieving information. > Lets say I have an index which contents a millions of documents with > 2-3 small fields an a 10 large fields. > Then I run a query which returns me a 1000 of hits. But I am > interested only one small field, and I don't want to load other > fields. > > Can I do something like what? > > int id = hits.id(n); > > FieldSelector fieldSelector = new FieldSelector() { > public FieldSelectorResult accept(String fieldName) { > if(fieldName.equals(field)) > return FieldSelectorResult.LOAD_AND_BREAK; > return FieldSelectorResult.NO_LOAD; > } > }; > > Document doc = reader.document(id, fieldSelector); > if(doc == null) > throw new IOException("Document with id "+id+" not found"); > return doc.get(field); > > n from 0 to hits.length(). > > Best regards, > Sergey > > --------------------------------------------------------------------- > To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org > For additional commands, e-mail: java-user-help@lucene.apache.org > -------------------------- Grant Ingersoll http://www.lucenebootcamp.com Next Training: April 7, 2008 at ApacheCon Europe in Amsterdam Lucene Helpful Hints: http://wiki.apache.org/lucene-java/BasicsOfPerformance http://wiki.apache.org/lucene-java/LuceneFAQ --------------------------------------------------------------------- To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org For additional commands, e-mail: java-user-help@lucene.apache.org