Wildcard query on non existent field matches all documents

fixes #2461
This commit is contained in:
Shay Banon 2012-12-07 19:36:40 +01:00
parent ea9a4d70cf
commit 4dec14d5da
1 changed files with 12 additions and 1 deletions

View File

@ -555,7 +555,18 @@ public class MapperQueryParser extends QueryParser {
if (termStr.equals("*")) {
// we want to optimize for match all query for the "*:*", and "*" cases
if ("*".equals(field) || Objects.equal(field, this.field)) {
return newMatchAllDocsQuery();
String actualField = field;
if (actualField == null) {
actualField = this.field;
}
if (actualField == null) {
return newMatchAllDocsQuery();
}
if ("_all".equals(actualField)) {
return newMatchAllDocsQuery();
}
// effectively, we check if a field exists or not
return fieldQueryExtensions.get(ExistsFieldQueryExtension.NAME).query(parseContext, actualField);
}
}
Collection<String> fields = extractMultiFields(field);