mirror of https://github.com/apache/lucene.git
LUCENE-7490: SimpleQueryParser now parses '*' as MatchAllDocsQuery
This commit is contained in:
parent
175370f232
commit
4ae1643f66
|
@ -53,6 +53,9 @@ New Features
|
|||
in postings for fast wildcard (MultiTermQuery) highlighting.
|
||||
(David Smiley, Timothy Rodriguez)
|
||||
|
||||
* LUCENE-7490: SimpleQueryParser now parses '*' to MatchAllDocsQuery
|
||||
(Lee Hinman via Mike McCandless)
|
||||
|
||||
Bug Fixes
|
||||
|
||||
* LUCENE-7472: MultiFieldQueryParser.getFieldQuery() drops queries that are
|
||||
|
|
|
@ -145,6 +145,10 @@ public class SimpleQueryParser extends QueryBuilder {
|
|||
|
||||
/** Parses the query text and returns parsed query */
|
||||
public Query parse(String queryText) {
|
||||
if ("*".equals(queryText.trim())) {
|
||||
return new MatchAllDocsQuery();
|
||||
}
|
||||
|
||||
char data[] = queryText.toCharArray();
|
||||
char buffer[] = new char[data.length];
|
||||
|
||||
|
|
|
@ -623,4 +623,11 @@ public class TestSimpleQueryParser extends LuceneTestCase {
|
|||
parseKeyword(sb.toString(), TestUtil.nextInt(random(), 0, 1024)); // no exception
|
||||
}
|
||||
}
|
||||
|
||||
public void testStarBecomesMatchAll() throws Exception {
|
||||
Query q = parse("*");
|
||||
assertEquals(q, new MatchAllDocsQuery());
|
||||
q = parse(" * ");
|
||||
assertEquals(q, new MatchAllDocsQuery());
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue