lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Chris Hostetter <>
Subject Re: using MultiFieldQueryParser and WildcardQuery?
Date Fri, 19 May 2006 02:55:31 GMT

I think you may have missunderstood his question, i believe what he was
saying that his current use of MultiFieldParser will give him ...blah...
based on the input string "white hard hat"; but what he'd like to get is
hte same final query structure, but with the individual clauses being
WildCardQUeries instead of TermQueries.

I haven't looked at the internals of MultFieldQueryParser before, but if
it's a well behaved subclass of QueryParser, you should be able to
override getFieldQuery to call getWildCardQuery, and get what you want.

All of hte performance issues described below however, still apply...

: Date: Thu, 18 May 2006 21:26:40 -0400
: From: Erick Erickson <>
: Reply-To:
: To:
: Subject: Re: using MultiFieldQueryParser and WildcardQuery?
: I'm pretty sure that just submitting the query will work. You might want to
: use the QueryParser(String, Analyzer) form. Don't be put off by the fact
: that the String is the "default field", it doesn't make any difference given
: that you qualify each term with the field. In fact, you can even use a
: PerFieldAnalyzerWrapper for the Analyzer and have different analyzers for
: each field "for free".
: That said, I really doubt you want to do this if you have much data. I fear
: you'll get a TooManyClauses exception. Lucene In Action describes the why of
: this, and "the guys" gave me a great service in the thread titled "I just
: don't get wildcards at all". The short form is that if you have more than
: 1024 terms that could be part of this query, you'll get this exception. You
: can bump the maximum number of clauses allowed, but that's a solution I'm
: leery as I'm sure it'll break sometime, probably just after I release it to
: my customers <G>.
: The solution I used was to subclass QueryParser and override the wildcard
: (and prefix and etc.) methods and return a ConstanScoreQuery with a Filter.
: The filter is built up by using a WildcardTermEnum. This may or may not work
: in your case, it depends on the characteristics of your data and query and
: response time expectations.
: Another approach is to use clever indexing. That is, when you index, overlay
: (see the synonyms discussion in LIA) index whiter, white, whit, whi, wh, w
: in the same position. Then you never have to search for a wildcard, you can
: just search for white and hit white and whiter.
: Anyway, I really recommend both LIA and the thread above, as well as
: searching the archives for wildcards.
: Best
: Erick


To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message