apache / apache/lucene

QueryParser should now allow leading '?' wildcards [LUCENE-2262]

Open
#3,338 10 comments 0 reactions 1 assignee Claimed by @rmuir View on GitHub
affects-version:4.0-ALPHA legacy-jira-fix-version:4.9 legacy-jira-fix-version:6.0 legacy-jira-priority:Minor module:core/queryparser type:enhancement
Dominant language
Java
Stars
3.6k
Forks
1.4k
Avg merge
2d 11h
Merged PRs (30d)
88

Description

QueryParser currently throws an exception if a wildcard term begins with the '?' operator.

The current documentation describes why this is:
```
When set, * or ? are allowed as the first character of a PrefixQuery and WildcardQuery.
Note that this can produce very slow queries on big indexes.
```

In the flexible indexing branch, wildcard queries with leading '?' operator are no longer slow on big indexes (they do not enumerate terms in linear fashion).
Thus, it no longer makes sense to throw a ParseException for a leading '?'

So, users should be able to perform a query of "?foo" and no longer get a ParseException from the QueryParser.

For the flexible indexing branch, wildcard queries of 'foo?', '?foo', 'f?oo', etc are all the same from a performance perspective.

---
Migrated from [LUCENE-2262](https://issues.apache.org/jira/browse/LUCENE-2262) by Robert Muir (@rmuir), updated May 09 2016
Attachments: [LUCENE-2262_backwards.patch](https://apache.github.io/lucene-jira-archive/attachments/LUCENE-2262/LUCENE-2262_backwards.patch), [LUCENE-2262.patch](https://apache.github.io/lucene-jira-archive/attachments/LUCENE-2262/LUCENE-2262.patch)

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.