Return-Path: Delivered-To: apmail-lucene-java-user-archive@www.apache.org Received: (qmail 12427 invoked from network); 23 Aug 2005 17:01:24 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 23 Aug 2005 17:01:24 -0000 Received: (qmail 40262 invoked by uid 500); 23 Aug 2005 17:01:19 -0000 Delivered-To: apmail-lucene-java-user-archive@lucene.apache.org Received: (qmail 40240 invoked by uid 500); 23 Aug 2005 17:01:19 -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 40227 invoked by uid 99); 23 Aug 2005 17:01:19 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 23 Aug 2005 10:01:19 -0700 X-ASF-Spam-Status: No, hits=0.0 required=10.0 tests= X-Spam-Check-By: apache.org Received-SPF: pass (asf.osuosl.org: local policy) Received: from [212.42.171.82] (HELO mail.runtime-collective.com) (212.42.171.82) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 23 Aug 2005 10:01:36 -0700 Received: from [81.168.89.246] (helo=[192.168.1.3]) by mail.runtime-collective.com with smtp (Exim 3.35 #1 (Debian)) id 1E7c93-0004hD-00 for ; Tue, 23 Aug 2005 18:01:09 +0100 Subject: Re: QueryParser not thread-safe From: Miles Barr To: java-user@lucene.apache.org In-Reply-To: References: Content-Type: text/plain Organization: Runtime Collective Ltd. Date: Tue, 23 Aug 2005 18:01:29 +0100 Message-Id: <1124816490.11257.81.camel@localhost.localdomain> Mime-Version: 1.0 X-Mailer: Evolution 2.2.2 Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N On Tue, 2005-08-23 at 13:47 -0300, jhandl@fibertel.com.ar wrote: > Hi! I've been having problems with lucene's QueryParser, apparently it is not thread-safe. > > That means I can't parse queries in threads where the queryparser object is created once and reused for each query. If I do, the resulting queries may have all kinds of weird problems, for example missing terms, duplicate terms, etc. > > I don't like the idea of creating a new queryparser for each query, so I am looking for alternatives. Any ideas? Using a non-threadsafe object in a threaded environment is fairly standard in Java, just wrap it in a synchronized block. If you don't want all threads waiting on one query parser, create a pool of them. -- Miles Barr Runtime Collective Ltd. --------------------------------------------------------------------- To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org For additional commands, e-mail: java-user-help@lucene.apache.org