lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ruchi Thakur <>
Subject Re: BooleanQuery TooManyClauses in wildcard search
Date Sat, 01 Dec 2007 06:16:30 GMT
  Erick/John, thank you so much for the reply. I have gone through the mailing list u have
redirected me  to. I know i need to read more, but some quick questions. Please bear with
me if they appear to be too simple.
  Below is the code snippet of my current search. Also i need to get score info of each of
my document returned in search, as i display the search result in the order of scroing.
   Directory fsDir = FSDirectory.getDirectory(aIndexDir, false);
   IndexSearcher is = new IndexSearcher(fsDir);
   ELSAnalyser elsAnalyser = new ELSStopAnalyser();
   Analyzer analyzer = elsAnalyser.getAnalyzer();
     QueryParser parser = new QueryParser(aIndexField, analyzer);
     Query query = parser.parse(aSearchStr);
     hits =;
  Now as i have understood, through the mail archives you have suggsted, below is what we
need to do.
  1)The second was to build a *Filter* that uses WildcardTermEnum -- not a 
  because it's a filter, the scoring aspects of each document are taken out of the equation
(I am worried abt it , as i need scoring info)
  2)Once you have a "WildcardFilter" wrapping it in a ConstantScoreQuery would give you a
drop in replacement for WildCardQuery that would sacrifive the TF/IDF scoring factors for
speed and garunteed execution on any pattern in any index regardless of size. (Does that mean
it will solve my scoring issue and i will get scoring info)
  Also it suggests "SpanNearQuery on a wildcard". I am kinda cofused which is the approach
that should be actually used. Please suggest. At the same time i am studing more abt it. Thanks
a lot for ur help on this.
  Best Regards,
Erick Erickson <> wrote:
  John's answer is spot-on. There's a wealth of information in the user group
archives that you should be able to search on discussing ways of providing
the functionality. One thread titled "I just don't get wildcards at all"
is one where the folks who know generously helped me out.

Once you find out how to search for that you'll know you're in the right
Here's the searchable archive.....;search_forum=forum_2;;list=lucene

Make sure you select the "java user" from the top drop-down labeled


On Nov 30, 2007 2:07 PM, John Byrne wrote:

> Hi,
> Your problem is that when you do a wildacrd search, Lucene expands the
> wildacrd term into all possible terms. So, searching for "stat*"
> produces a list of terms like "state", "states", "stating" etc. (It only
> uses terms that actually occur in your index, however). These terms are
> all added as OR clauses of a boolean query.
> The thing is, be defult, there is a limit of 1024 caluses for a boolean
> query. If yuor wildacrd term expands into more than this, (which happens
> very easily), you get that exception you described. You can solve the
> issues by setting the maximum clause count yourself, using
> BooleanQuery.setMaxClauseCount(int maxClauseCount)
> See
> for mroe info.
> Bear in mind that putting a wildcard near the start of the term results
> in a large number of boolean clauses, which increases memory usage. This
> is the reason for the default limit. This limit will also affect fuzzy
> queries, because they are expanded in the same way.
> Regards,
> JB
> Ruchi Thakur wrote:
> >
> > Hi there.
> > I am a new Lucene user and I have been searching the group archives but
> couldn't solve the problem. I have just joined a project that uses Lucene.
> > We use the StandardAnalyzer for indexing our documents and our query is
> as
> > follows when we issue a search string of t* for example:
> > +t* +cont_type:pa
> >
> > We get an Exception when we issue some of our wildcard text searches
> we get following Exception
> >$TooManyClauses Exception : Max
> clause if 1024
> >
> > Please suggest.
> >
> > Regards,
> > Ruchi
> >
> >
> >
> >
> >
> >
> >
> >
> > ---------------------------------
> > Never miss a thing. Make Yahoo your homepage.
> >
> > ------------------------------------------------------------------------
> >
> > No virus found in this incoming message.
> > Checked by AVG Free Edition.
> > Version: 7.5.503 / Virus Database: 269.16.11/1161 - Release Date:
> 30/11/2007 12:12
> >
> ---------------------------------------------------------------------
> To unsubscribe, e-mail:
> For additional commands, e-mail:

Be a better pen pal. Text or chat with friends inside Yahoo! Mail. See how.
  • Unnamed multipart/alternative (inline, 8-Bit, 0 bytes)
View raw message