Return-Path: Delivered-To: apmail-lucene-java-user-archive@www.apache.org Received: (qmail 71023 invoked from network); 11 Dec 2007 14:00:19 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 11 Dec 2007 14:00:19 -0000 Received: (qmail 13092 invoked by uid 500); 11 Dec 2007 13:59:51 -0000 Delivered-To: apmail-lucene-java-user-archive@lucene.apache.org Received: (qmail 13055 invoked by uid 500); 11 Dec 2007 13:59:51 -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 12343 invoked by uid 99); 11 Dec 2007 13:59:48 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 11 Dec 2007 05:59:48 -0800 X-ASF-Spam-Status: No, hits=0.2 required=10.0 tests=SPF_PASS,WHOIS_MYPRIVREG X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: local policy) Received: from [63.65.184.134] (HELO birexchange.BIRPLAZA.local) (63.65.184.134) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 11 Dec 2007 13:59:26 +0000 Content-class: urn:content-classes:message MIME-Version: 1.0 Subject: RE: Post processing to get around TooManyClauses? Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: quoted-printable Date: Tue, 11 Dec 2007 08:59:27 -0500 X-MimeOLE: Produced By Microsoft Exchange V6.5.6944.0 Message-ID: X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: Post processing to get around TooManyClauses? Thread-Index: Acg7+Eh0LSrk4Z55S5qGcSg/W4W5CQABBvHQ From: "Beard, Brian" To: X-Virus-Checked: Checked by ClamAV on apache.org I had a similar problem (I think). Look at using a WildcardFilter (below), possibly wrapped in a CachingWrapperFilter, depending if you want to re-use it. I over-rode the method QueryParser.getWildcardQuery to customize it. In your case you would probably have to specifically detect for the presence of a wildcard to use this. Someone posted this a while back which I found helpful. /** * This is used to construct wildcard queries * to avoid the 'too many boolean clauses' exception. * */ public class WildcardFilter extends Filter { private Term term; public WildcardFilter(Term term) { this.term =3D term; } /** * A bit corrresponds to each document in the index and is set to true if * it matches the criterion in the wildcard search. *=20 * @param reader - the indexReader @see org.apache.lucene.index.IndexReader * @return @see org.apache.lucene.search.Filter#bits() */ @Override public BitSet bits(IndexReader reader) throws IOException { BitSet bits =3D new BitSet(reader.maxDoc()); WildcardTermEnum enumerator =3D new WildcardTermEnum(reader, term); TermDocs termDocs =3D reader.termDocs(); try { do { Term term =3D enumerator.term(); if (term !=3D 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: d33mb33 [mailto:david.balzan@entity.co.uk]=20 Sent: Tuesday, December 11, 2007 8:18 AM To: java-user@lucene.apache.org Subject: Re: Post processing to get around TooManyClauses? Ok I'm still struggling with this and a QueryFilter didn't help me one bit :-( I'm trying to query for books by "Charles Dickens" that start with "m". I have constructed a QueryFilter for the author search and a PrefixQuery for the title search. A simplified version of my code is below. ' Charles Dickens query filter Dim authorQry As TermQuery =3D New TermQuery(New Term("ContributorName", "dickens")) Dim authorFlter As QueryFilter =3D New QueryFilter(authorQry) ' M* query Dim titleQry As PrefixQuery =3D New PrefixQuery(New Term("Title", "m")) Dim topDocs As TopDocs =3D GetIndexSearcher().Search(titleQry, authorFlter, maxResults) This still throws a TooManyClauses exception because the PrefixQuery is being expanded across the entire index. =20 --=20 View this message in context: http://www.nabble.com/Post-processing-to-get-around-TooManyClauses--tp14 210833p14273737.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 --------------------------------------------------------------------- To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org For additional commands, e-mail: java-user-help@lucene.apache.org