mirror of https://github.com/apache/lucene.git
QueryParsing.parseQuery(String,IndexSchema) and QueryParsing.parseQuery(String,String,IndexSchema) now
respects the schema.xml <solrQueryParser defaultOperator="..."/> setting. Before, only QueryParsing.parseQuery(String,String,SolrParams,IndexSchema) respected the schema setting. SolrQueryParser itself now sets the default operator based on the schema setting, and is overridden with the q.op param when the latter QueryParsing.parseQuery() method is used. git-svn-id: https://svn.apache.org/repos/asf/lucene/solr/trunk@510334 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
95158fda84
commit
3b968a0bc9
|
@ -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)) {
|
||||
|
|
|
@ -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 {
|
||||
|
|
Loading…
Reference in New Issue