diff --git a/src/main/java/org/apache/lucene/queryparser/classic/MapperQueryParser.java b/src/main/java/org/apache/lucene/queryparser/classic/MapperQueryParser.java index ba74339ab92..2ed9f28ae37 100644 --- a/src/main/java/org/apache/lucene/queryparser/classic/MapperQueryParser.java +++ b/src/main/java/org/apache/lucene/queryparser/classic/MapperQueryParser.java @@ -562,7 +562,7 @@ public class MapperQueryParser extends QueryParser { if (actualField == null) { return newMatchAllDocsQuery(); } - if ("_all".equals(actualField)) { + if ("*".equals(actualField) || "_all".equals(actualField)) { return newMatchAllDocsQuery(); } // effectively, we check if a field exists or not diff --git a/src/test/java/org/elasticsearch/test/unit/index/query/SimpleIndexQueryParserTests.java b/src/test/java/org/elasticsearch/test/unit/index/query/SimpleIndexQueryParserTests.java index 942d025ee0f..4eb413e8c30 100644 --- a/src/test/java/org/elasticsearch/test/unit/index/query/SimpleIndexQueryParserTests.java +++ b/src/test/java/org/elasticsearch/test/unit/index/query/SimpleIndexQueryParserTests.java @@ -257,6 +257,17 @@ public class SimpleIndexQueryParserTests { 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 public void testDisMaxBuilder() throws Exception { IndexQueryParserService queryParser = queryParser(); diff --git a/src/test/java/org/elasticsearch/test/unit/index/query/starColonStar.json b/src/test/java/org/elasticsearch/test/unit/index/query/starColonStar.json new file mode 100644 index 00000000000..c769ca09380 --- /dev/null +++ b/src/test/java/org/elasticsearch/test/unit/index/query/starColonStar.json @@ -0,0 +1,5 @@ +{ + "query_string": { + "query": "*:*" + } +} \ No newline at end of file