lucene-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Christoph Kaser (JIRA)" <j...@apache.org>
Subject [jira] [Created] (LUCENE-4773) QueryParserBase should not throw ParseException in getPrefixQuery when termStr starts with *
Date Tue, 12 Feb 2013 10:45:12 GMT
Christoph Kaser created LUCENE-4773:
---------------------------------------

             Summary: QueryParserBase should not throw ParseException in getPrefixQuery when
termStr starts with *
                 Key: LUCENE-4773
                 URL: https://issues.apache.org/jira/browse/LUCENE-4773
             Project: Lucene - Core
          Issue Type: Bug
          Components: core/queryparser
    Affects Versions: 4.1, 4.0
            Reporter: Christoph Kaser
            Priority: Minor


The method getPrefixQuery of org.apache.lucene.queryparser.classic.QueryParserBase checks
for leading *-wildcards:

{code:java}
protected Query getPrefixQuery(String field, String termStr) throws ParseException
  {
    if (!allowLeadingWildcard && termStr.startsWith("*"))
      throw new ParseException("'*' not allowed as first character in PrefixQuery");
    ...
  }
{code}

However, the passed termStr is already unescaped in handleBareTokenQuery(...):
{code:java}
 q = getPrefixQuery(qfield,
          discardEscapeChar(term.image.substring
              (0, term.image.length()-1)));
{code}

Therefore, a search query like this one results in a ParseException, even though the first
wildcard is escaped:
{noformat}
title:\*a*
{noformat}

I don't think there is any sense in checking for leading wildcards in getPrefixQuery, as the
passed termStr is already used literally, without paying attention to special characters at
all.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: dev-help@lucene.apache.org


Mime
View raw message