lucene-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Hoss Man (JIRA)" <>
Subject [jira] Commented: (LUCENE-2458) queryparser shouldn't generate phrasequeries based on term count
Date Wed, 12 May 2010 19:10:43 GMT


Hoss Man commented on LUCENE-2458:

bq. Instead the queryparser should only form phrasequeries when you use double quotes, just
like the documentation says.

i'll grant you that the documentation is wrong -- i view that as a bug in the documentation,
not the code.  

Saying that a PhraseQuery object should only ever be constructed if the user uses quotes is
like saying that a BooleanQuery should only ever be constructed if the user specifies boolean
operators -- there is no rule that the syntax must match the query structure, the same Query
classes can serve multiple purposes.  The parser syntax should be what makes sense  for hte
user, and the query structure constructed should be what makes sense for hte index, based
on the syntax used by the user.

If i have built an index consisting entirely of ngrams, the end user shouldn't have to know
that -- they shouldn't have to put every individual word in quotes to force a PhraseQuery
to be constructed out of the ngram tokenstream produced by an individual word.

bq. Why isn't english treated this way too? I don't consider this bias towards english "at
all costs" including preventing languages such as Chinese from working at all very fair, I
think its a really ugly stance for Lucene to take.

I personally don't view it as an "english bias" ... to be it is a "backwards compatibility

I'm totally happy to make things onfigurable, but if two diametrically opposed behaviors are
both equally useful, and If there is a choice needs to be made between leaving the default
configuration the way the current hardcoded behavior is, or make the default the exact opposite
of what the current hardcoded behavior is, it is then i would prefer to leave the default
alone -- especially since this beahior has been around for so long, and many Analyzers and
TOkenFilters, have been written with this behavior specificly in mind (several examples of
this are in the Lucene code base -- and if we have them in our own code, you can be sure they
exist "in the wild" of client code that would break if this behavior changes by default)

Once again: if this is a problem that can be solved "per instance" with token attributes,
then by all means let's make *all* of the TokenFIlters that come "out of the box" implement
this appropriately (english and non-english alike) so that people who change the default settings
on the queryparser get the "correct" behavior regardless of langauge.  but all other things
being equal lets keep the behavior working the way it has to avoid suprises.

bq. What are some real use-cases where this is "good"?

 * WordDelimiterFilter ("wi-fi" is a pathalogicaly bad example for this issue because as robert
pointed out "wi" and "fi" don't tend to exist independently in english, but people tend to
get anoyed when "race-horse" matches all docs containing "race" or "horse")
 * single word to multiword synonym expansion/transformation (particularly acronym expansion:
GE => General Electric)
 * Ngram indexing for fuzzy matching (if someone searches for the word billionaire they're
going to be surprised to get documents containing "lion")

> queryparser shouldn't generate phrasequeries based on term count
> ----------------------------------------------------------------
>                 Key: LUCENE-2458
>                 URL:
>             Project: Lucene - Java
>          Issue Type: Bug
>          Components: QueryParser
>            Reporter: Robert Muir
>            Priority: Critical
> The current method in the queryparser to generate phrasequeries is wrong:
> The Query Syntax documentation (
> {noformat}
> A Phrase is a group of words surrounded by double quotes such as "hello dolly".
> {noformat}
> But as we know, this isn't actually true.
> Instead the terms are first divided on whitespace, then the analyzer term count is used
as some sort of "heuristic" to determine if its a phrase query or not.
> This assumption is a disaster for languages that don't use whitespace separation: CJK,
compounding European languages like German, Finnish, etc. It also
> makes it difficult for people to use n-gram analysis techniques. In these cases you get
bad relevance (MAP improves nearly *10x* if you use a PositionFilter at query-time to "turn
this off" for chinese).
> For even english, this undocumented behavior is bad. Perhaps in some cases its being
abused as some heuristic to "second guess" the tokenizer and piece back things it shouldn't
have split, but for large collections, doing things like generating phrasequeries because
StandardTokenizer split a compound on a dash can cause serious performance problems. Instead
people should analyze their text with the appropriate methods, and QueryParser should only
generate phrase queries when the syntax asks for one.
> The PositionFilter in contrib can be seen as a workaround, but its pretty obscure and
people are not familiar with it. The result is we have bad out-of-box behavior for many languages,
and bad performance for others on some inputs.
> I propose instead that we change the grammar to actually look for double quotes to determine
when to generate a phrase query, consistent with the documentation.

This message is automatically generated by JIRA.
You can reply to this email to add a comment to the issue online.

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

View raw message