lucene-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Michael Busch (JIRA)" <>
Subject [jira] Commented: (LUCENE-588) Escaped wildcard character in wildcard term not handled correctly
Date Sat, 24 May 2008 22:31:55 GMT


Michael Busch commented on LUCENE-588:

I think we should add a new constructor to WildcardQuery like this:

  public WildcardQuery(Term term) {
    this(term, WildcardTermEnum.WILDCARD_CHAR, WildcardTermEnum.WILDCARD_STRING);
  public WildcardQuery(Term term, char wildcardChar, char wildcardString) {
    this.wildcardChar = wildcardChar;
    this.wildcardString = wildcardString;
    this.termContainsWildcard = (term.text().indexOf(wildcardChar) != -1) 
                                || (term.text().indexOf(wildcardString) != -1);

Then the WildcardQuery doesn't need to know anything about escaping and the QueryParser
can just map wildcard characters that weren't escaped to some other unused chars and can
unescape * and ? chars.

The only disadvantage of this design would be that the WildcardQuery.toString() would not
produce a String anymore that the QueryParser could parse. However, I think the requirement
of Query.toString() to produce a parseable String is not very good anyways, because it adds
a dependency between the Query classes and the QueryParser. I'd prefer to add a method
String toQueryString(Query);
to the QueryParser. Then Query.toString() wouldn't be tied anymore to a specific QueryParser
implementation and syntax. Thoughts?

Terry are you still around? Would you like to work on a new patch here?

> Escaped wildcard character in wildcard term not handled correctly
> -----------------------------------------------------------------
>                 Key: LUCENE-588
>                 URL:
>             Project: Lucene - Java
>          Issue Type: Bug
>          Components: QueryParser
>    Affects Versions: 2.0.0
>         Environment: Windows XP SP2
>            Reporter: Sunil Kamath
>            Assignee: Michael Busch
>            Priority: Minor
>         Attachments: LUCENE-588.patch
> If an escaped wildcard character is specified in a wildcard query, it is treated as a
wildcard instead of a literal.
> e.g., t\??t is converted by the QueryParser to t??t - the escape character is discarded.

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