Correctly parse *:* query into matchAllDocsQuery

Fixes #2486
This commit is contained in:
Igor Motov 2012-12-14 14:36:20 -08:00
parent 148dc3c013
commit c8285739d2
3 changed files with 17 additions and 1 deletions

View File

@ -562,7 +562,7 @@ public class MapperQueryParser extends QueryParser {
if (actualField == null) { if (actualField == null) {
return newMatchAllDocsQuery(); return newMatchAllDocsQuery();
} }
if ("_all".equals(actualField)) { if ("*".equals(actualField) || "_all".equals(actualField)) {
return newMatchAllDocsQuery(); return newMatchAllDocsQuery();
} }
// effectively, we check if a field exists or not // effectively, we check if a field exists or not

View File

@ -257,6 +257,17 @@ public class SimpleIndexQueryParserTests {
assertThat((double) matchAllDocsQuery.getBoost(), closeTo(1.2, 0.01)); assertThat((double) matchAllDocsQuery.getBoost(), closeTo(1.2, 0.01));
} }
@Test
public void testStarColonStar() throws Exception {
IndexQueryParserService queryParser = queryParser();
String query = copyToStringFromClasspath("/org/elasticsearch/test/unit/index/query/starColonStar.json");
Query parsedQuery = queryParser.parse(query).query();
assertThat(parsedQuery, instanceOf(ConstantScoreQuery.class));
ConstantScoreQuery constantScoreQuery = (ConstantScoreQuery) parsedQuery;
Filter internalFilter = constantScoreQuery.getFilter();
assertThat(internalFilter, instanceOf(MatchAllDocsFilter.class));
}
@Test @Test
public void testDisMaxBuilder() throws Exception { public void testDisMaxBuilder() throws Exception {
IndexQueryParserService queryParser = queryParser(); IndexQueryParserService queryParser = queryParser();

View File

@ -0,0 +1,5 @@
{
"query_string": {
"query": "*:*"
}
}