lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Paul Elschot <>
Subject Re: Why Lucene has to rewrite queries prior to actual searching?
Date Mon, 07 Apr 2008 21:56:35 GMT

Query rewrite replaces wildcards with terms available from
the index. Usually that involves replacing a wildcard with a 
BooleanQuery that is an effective OR over the available
terms while using a flat coordination factor, i.e. it does not
matter how many of the available terms actually match
a document, as long as at least one matches.

For the required query parts (AND like), Scorer.skipTo()
is used, and that could well be the filter mechanism you
are referring to; have a look at the javadocs of Scorer,
and, if necessary, at the actual code of ConjunctionScorer.

Paul Elschot

Op Monday 07 April 2008 23:13:09 schreef Itamar Syn-Hershko:
> Hi all,
> Can someone from the experts here explain why Lucene has to get a
> "rewritten" query for the Searcher - so Phrase or Wildcards queries
> have to rewrite themselves into a "primitive" query, that is then
> passed to Lucene to look for? I'm probably not familiar too much with
> the internals of Lucene, but I'd imagine that if you can inflate a
> query using wildcards via xxxxQuery sub classing, you could as easily
> (?) have some sort of Filter mechanism during the search, so that
> Lucene retrieves the Position vectors for all the terms that pass
> that filter, instead of retrieving only the position data for
> deterministic terms (with no wildcards etc.). If that was possible to
> do somehow, it could greatly increase the searchability of Lucene
> indices by using RegEx (without re-writing and getting the dreaded
> MaxClauseCount error) and similar.
> Would love to hear some insights on this one.
> Itamar.

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

View raw message