mirror of https://github.com/apache/lucene.git
LUCENE-7490: SimpleQueryParser now parses '*' as MatchAllDocsQuery
This commit is contained in:
parent
f10312a4c4
commit
67d206c665
|
@ -15,6 +15,9 @@ New Features
|
||||||
in postings for fast wildcard (MultiTermQuery) highlighting.
|
in postings for fast wildcard (MultiTermQuery) highlighting.
|
||||||
(David Smiley, Timothy Rodriguez)
|
(David Smiley, Timothy Rodriguez)
|
||||||
|
|
||||||
|
* LUCENE-7490: SimpleQueryParser now parses '*' to MatchAllDocsQuery
|
||||||
|
(Lee Hinman via Mike McCandless)
|
||||||
|
|
||||||
Bug Fixes
|
Bug Fixes
|
||||||
|
|
||||||
* LUCENE-7472: MultiFieldQueryParser.getFieldQuery() drops queries that are
|
* 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 */
|
/** Parses the query text and returns parsed query */
|
||||||
public Query parse(String queryText) {
|
public Query parse(String queryText) {
|
||||||
|
if ("*".equals(queryText.trim())) {
|
||||||
|
return new MatchAllDocsQuery();
|
||||||
|
}
|
||||||
|
|
||||||
char data[] = queryText.toCharArray();
|
char data[] = queryText.toCharArray();
|
||||||
char buffer[] = new char[data.length];
|
char buffer[] = new char[data.length];
|
||||||
|
|
||||||
|
|
|
@ -626,4 +626,11 @@ public class TestSimpleQueryParser extends LuceneTestCase {
|
||||||
parseKeyword(sb.toString(), TestUtil.nextInt(random(), 0, 1024)); // no exception
|
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