diff --git a/src/java/org/apache/solr/search/QueryParsing.java b/src/java/org/apache/solr/search/QueryParsing.java index 73d6aeadaae..8f18fda6e13 100644 --- a/src/java/org/apache/solr/search/QueryParsing.java +++ b/src/java/org/apache/solr/search/QueryParsing.java @@ -85,10 +85,11 @@ public class QueryParsing { */ public static Query parseQuery(String qs, String defaultField, SolrParams params, IndexSchema schema) { try { - String opParam = params.get(OP, schema.getQueryParserDefaultOperator()); - QueryParser.Operator defaultOperator = "AND".equals(opParam) ? QueryParser.Operator.AND : QueryParser.Operator.OR; SolrQueryParser parser = new SolrQueryParser(schema, defaultField); - parser.setDefaultOperator(defaultOperator); + String opParam = params.get(OP); + if (opParam != null) { + parser.setDefaultOperator("AND".equals(opParam) ? QueryParser.Operator.AND : QueryParser.Operator.OR); + } Query query = parser.parse(qs); if (SolrCore.log.isLoggable(Level.FINEST)) { diff --git a/src/java/org/apache/solr/search/SolrQueryParser.java b/src/java/org/apache/solr/search/SolrQueryParser.java index bf15dec4508..2a92b984ef9 100644 --- a/src/java/org/apache/solr/search/SolrQueryParser.java +++ b/src/java/org/apache/solr/search/SolrQueryParser.java @@ -60,6 +60,8 @@ public class SolrQueryParser extends QueryParser { super(defaultField == null ? schema.getDefaultSearchFieldName() : defaultField, schema.getQueryAnalyzer()); this.schema = schema; setLowercaseExpandedTerms(false); + String operator = schema.getQueryParserDefaultOperator(); + setDefaultOperator("AND".equals(operator) ? QueryParser.Operator.AND : QueryParser.Operator.OR); } protected Query getFieldQuery(String field, String queryText) throws ParseException {