Skip to content

Commit

Permalink
handle null query returning from query parsers properly
Browse files Browse the repository at this point in the history
now that we support "null" queries, for example, when parsing a query and its lenient, make sure to handle it where applicable
  • Loading branch information
kimchy authored and martijnvg committed Aug 9, 2012
1 parent e184a77 commit dff3b61
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,9 @@ public Query parse(QueryParseContext parseContext) throws IOException, QueryPars

try {
query = queryParser.parse(qpSettings.queryString());
if (query == null) {
return null;
}
query.setBoost(qpSettings.boost());
query = optimizeQuery(fixNegativeQueryIfNeeded(query));
if (query instanceof BooleanQuery) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,9 @@ public Query parse(QueryParseContext parseContext) throws IOException, QueryPars
}

Query query = matchQuery.parse(type, fieldName, text);
if (query == null) {
return null;
}

if (query instanceof BooleanQuery) {
Queries.applyMinimumShouldMatch((BooleanQuery) query, minimumShouldMatch);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,9 @@ public Query parse(QueryParseContext parseContext) throws IOException, QueryPars
}

Query query = multiMatchQuery.parse(type, fieldNames, text);
if (query == null) {
return null;
}

if (query instanceof BooleanQuery) {
Queries.applyMinimumShouldMatch((BooleanQuery) query, minimumShouldMatch);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,9 @@ public Query parse(QueryParseContext parseContext) throws IOException, QueryPars

try {
query = queryParser.parse(qpSettings.queryString());
if (query == null) {
return null;
}
query.setBoost(qpSettings.boost());
query = optimizeQuery(fixNegativeQueryIfNeeded(query));
if (query instanceof BooleanQuery) {
Expand Down

0 comments on commit dff3b61

Please sign in to comment.