: I believe now having SolrQueryParser set the operator based on the : schema configuration is much more sensible.
I haven't looked at this in depth, but i *think* this breaks the DisMaxQueryParser (i'm guessing AND isn't the default in our test config) i remember discussing this before, and suggesting that SolrQueryParser should use the schema only for understanding field types, so calling the basic constructor gives you a barebones SOlrQUeryParser; and any other options (like default op) could be set in a utility/factory method. http://www.nabble.com/QueryParser-default-operator---AND-tf1977319.html#a5425365 : On Feb 21, 2007, at 8:00 PM, [EMAIL PROTECTED] wrote: : : > Author: ehatcher : > Date: Wed Feb 21 17:00:23 2007 : > New Revision: 510334 : > : > URL: http://svn.apache.org/viewvc?view=rev&rev=510334 : > Log: : > 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. : > : > : > Modified: : > lucene/solr/trunk/src/java/org/apache/solr/search/ : > QueryParsing.java : > lucene/solr/trunk/src/java/org/apache/solr/search/ : > SolrQueryParser.java : > : > Modified: lucene/solr/trunk/src/java/org/apache/solr/search/ : > QueryParsing.java : > URL: http://svn.apache.org/viewvc/lucene/solr/trunk/src/java/org/ : > apache/solr/search/QueryParsing.java? : > view=diff&rev=510334&r1=510333&r2=510334 : > ====================================================================== : > ======== : > --- lucene/solr/trunk/src/java/org/apache/solr/search/ : > QueryParsing.java (original) : > +++ lucene/solr/trunk/src/java/org/apache/solr/search/ : > QueryParsing.java Wed Feb 21 17:00:23 2007 : > @@ -85,10 +85,11 @@ : > */ : > 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)) { : > : > Modified: lucene/solr/trunk/src/java/org/apache/solr/search/ : > SolrQueryParser.java : > URL: http://svn.apache.org/viewvc/lucene/solr/trunk/src/java/org/ : > apache/solr/search/SolrQueryParser.java? : > view=diff&rev=510334&r1=510333&r2=510334 : > ====================================================================== : > ======== : > --- lucene/solr/trunk/src/java/org/apache/solr/search/ : > SolrQueryParser.java (original) : > +++ lucene/solr/trunk/src/java/org/apache/solr/search/ : > SolrQueryParser.java Wed Feb 21 17:00:23 2007 : > @@ -60,6 +60,8 @@ : > 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 { : > : -Hoss