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:
Erik Hatcher 2007-02-22 01:00:23 +00:00
parent 95158fda84
commit 3b968a0bc9
2 changed files with 6 additions and 3 deletions

View File

@ -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)) {

View File

@ -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 {