Return-Path: Delivered-To: apmail-jakarta-lucene-user-archive@www.apache.org Received: (qmail 34372 invoked from network); 13 Feb 2004 18:33:21 -0000 Received: from daedalus.apache.org (HELO mail.apache.org) (208.185.179.12) by minotaur-2.apache.org with SMTP; 13 Feb 2004 18:33:21 -0000 Received: (qmail 84066 invoked by uid 500); 13 Feb 2004 18:32:44 -0000 Delivered-To: apmail-jakarta-lucene-user-archive@jakarta.apache.org Received: (qmail 83989 invoked by uid 500); 13 Feb 2004 18:32:43 -0000 Mailing-List: contact lucene-user-help@jakarta.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Subscribe: List-Help: List-Post: List-Id: "Lucene Users List" Reply-To: "Lucene Users List" Delivered-To: mailing list lucene-user@jakarta.apache.org Received: (qmail 83905 invoked from network); 13 Feb 2004 18:32:42 -0000 Received: from unknown (HELO server007.webpack.hosteurope.de) (80.237.130.15) by daedalus.apache.org with SMTP; 13 Feb 2004 18:32:42 -0000 Received: from 80.129.82.222 (p508152DE.dip0.t-ipconnect.de [80.129.82.222]) (authenticated bits=0) by server007.webpack.hosteurope.de (8.12.8/8.12.8) with ESMTP id i1DIWiqI013169 for ; Fri, 13 Feb 2004 19:32:44 +0100 Date: Fri, 13 Feb 2004 19:34:43 +0100 From: Ramy Hardan X-Mailer: The Bat! (v2.00.6) Reply-To: Ramy Hardan X-Priority: 3 (Normal) Message-ID: <12728216593.20040213193443@hardan.de> To: "Lucene Users List" Subject: Re: Limiting hit count In-Reply-To: <200402131512.11272.lucene@nitwit.de> References: <200402131134.54675.lucene@nitwit.de> <200402131302.14480.lucene@nitwit.de> <4D8D1092-5E2D-11D8-978C-000393A564E6@ehatchersolutions.com> <200402131512.11272.lucene@nitwit.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N X-Spam-Rating: minotaur-2.apache.org 1.6.2 0/1000/N Hi, > ...I actually only want the first hit If you say you want the first hit, do you mean any hit or the one that's usually first in Hits? The latter is the one with the highest score, so interrupting the search won't help you, since you don't know when the highest score is reached before examining all documents. > On Friday 13 February 2004 15:02, Erik Hatcher wrote: >> Use a HitCollector and grab the first one that comes in, then bail out. >> That should do the trick for getting the first hit only. > According to the API docs I ought to use HitCollector only if I need all > hits :-) And there's certainly a reason for it - I don't think that this will > speed up the search ;) I agree that bailing out of the HitCollector is a bad idea, because the only way to achieve this is to throw an exception. Probably Lucene finishes searching, creates the Hits object and cooks a meal long before the VM is able to build the stack trace and execute your catch clause ;) Ramy --------------------------------------------------------------------- To unsubscribe, e-mail: lucene-user-unsubscribe@jakarta.apache.org For additional commands, e-mail: lucene-user-help@jakarta.apache.org