Return-Path: Delivered-To: apmail-lucene-java-user-archive@www.apache.org Received: (qmail 64859 invoked from network); 18 Apr 2008 16:25:51 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 18 Apr 2008 16:25:51 -0000 Received: (qmail 68294 invoked by uid 500); 18 Apr 2008 16:25:44 -0000 Delivered-To: apmail-lucene-java-user-archive@lucene.apache.org Received: (qmail 68265 invoked by uid 500); 18 Apr 2008 16:25:44 -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 68254 invoked by uid 99); 18 Apr 2008 16:25:44 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 18 Apr 2008 09:25:44 -0700 X-ASF-Spam-Status: No, hits=2.0 required=10.0 tests=HTML_MESSAGE,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of chose77@gmail.com designates 64.233.178.240 as permitted sender) Received: from [64.233.178.240] (HELO hs-out-0708.google.com) (64.233.178.240) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 18 Apr 2008 16:25:01 +0000 Received: by hs-out-0708.google.com with SMTP id 4so409479hsl.5 for ; Fri, 18 Apr 2008 09:25:13 -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:to:subject:in-reply-to:mime-version:content-type:references; bh=CXY9RDB5NDsT1xa4YkiyaJh94cBGdlN/uvLoAt2hYdA=; b=hHqteOOAlYCJjZtNftUlhpixarePL2TwvxhgzrJEGa33f2BuV2g8SLasrXXsOFYmDXDK5xuDdo2t5e6HbnX4m8QmapDG4AaOcqYcOWQmc7G4PhAqKSN206yOPvsYIpFbzLYd2eWNuhPL1Pf6P1deeTTnSGDDNBXbMf619i5C47k= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:to:subject:in-reply-to:mime-version:content-type:references; b=UX6F+4g/3WiYDeRPwxCba435nEQM8DWpJ8n0H6YuUq+kqWDkeag6Q1QgSe1dLwHwqooMBdUopbn/iP9h9WXbE3TeBHbagEmnC0FiWBUdllfSM59jCypb3ACP8KMAJAPlwrDdiyT8N7hFaeYuwTMxjH19VEQiDGwhZOZMXKCNBD4= Received: by 10.100.133.1 with SMTP id g1mr5484295and.88.1208535913411; Fri, 18 Apr 2008 09:25:13 -0700 (PDT) Received: by 10.100.198.11 with HTTP; Fri, 18 Apr 2008 09:25:13 -0700 (PDT) Message-ID: Date: Fri, 18 Apr 2008 18:25:13 +0200 From: "Joe K" To: java-user@lucene.apache.org Subject: Re: WildCardQuery and TooManyClauses In-Reply-To: MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_Part_5842_14971616.1208535913393" References: X-Virus-Checked: Checked by ClamAV on apache.org ------=_Part_5842_14971616.1208535913393 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline Thank you very much Brian, this works for me! Chose On Mon, Apr 14, 2008 at 8:58 PM, Beard, Brian wrote: > You can use your approach w/ or w/o the filter. > > td = indexSearcher.search(query, filter, maxnumhits); > > You need to use a filter for the wildcards which is built in to the > query. > > 1) Extend QueryParser to override the getWildcardQuery method. > (Or even if you don't use QueryParser, just use the query api and > combine the ConstantScoreQuery in #2 with your own query). > 2) Inside of getWildcardQuery you need to return a > ConstantScoreQuery(new WildcardFilter(new Term(field, termStr))) > 3) The first execution will take longer to initialize, but subsequent > searches are fairly fast. > 4) Someone posted a WildcardFilter a while back which is below. > 5) Now you can plug in to topDocs. > > public class WildcardFilter extends Filter { > > ... > > public BitSet bits(IndexReader reader) throws IOException { > BitSet bits = new BitSet(reader.maxDoc()); > WildcardTermEnum enumerator = new WildcardTermEnum(reader, > term); > TermDocs termDocs = reader.termDocs(); > > try { > do { > Term term = enumerator.term(); > > if (term != null) { > termDocs.seek(term); > > while (termDocs.next()) { > bits.set(termDocs.doc()); > } > } else { > break; > } > } while (enumerator.next()); > } finally { > termDocs.close(); > enumerator.close(); > } > > return bits; > } > -----Original Message----- > From: Joe K [mailto:chose77@gmail.com] > Sent: Thursday, April 10, 2008 11:46 AM > To: java-user@lucene.apache.org > Subject: Re: WildCardQuery and TooManyClauses > > Donna, > so this doesn't work because search calls internaly > MultiTermQuery.rewrite > which causes TooManyClauses exception anyway even if the maxnumhits > is set to 200 !! > > So I am lost again... > > Chose > > > On Thu, Apr 10, 2008 at 3:02 PM, Donna L Gresh wrote: > > > Doesn't the following do what you want with maxnumhits =200? > > TopDocs td; > > td = indexSearcher.search(query, filter, maxnumhits); > > where filter can be null > > > > > > > > Donna L. Gresh > > Services Research, Mathematical Sciences Department > > IBM T.J. Watson Research Center > > (914) 945-2472 > > http://www.research.ibm.com/people/g/donnagresh > > gresh@us.ibm.com > > > > > > "Joe K" wrote on 04/10/2008 08:53:06 AM: > > > > > Hello everybody, > > > I know there was written a tons of words about this issue, but I'm > just > > not > > > clear enough about it. > > > > > > I have these facts: > > > > > > 1. my query is always 1 letter and *, eg. M* > > > 2. i always want to get max 200 results, no more! > > > 3. i don't want to fix this issue by setting maxClauseCount > > > > > > I just don't see the easy way how to get my results, did i missed > > something? > > > > > > From what I've read here I know that probably i should play with > filters > > or > > > with WildCardEnum, but why? > > > I just want to get simple this: > > > SELECT FROM XXX WHERE XXX.name LIKE 'M%' LIMIT 200; > > > > > > (there is no filtering in this query except the wildcard itself) > > > > > > Please, what is the easiest solution to achieve this? > > > > > > Thanks in advance, > > > Chose > > > > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org > For additional commands, e-mail: java-user-help@lucene.apache.org > > ------=_Part_5842_14971616.1208535913393--