public QParser createParser(String qstr, SolrParams localParams, SolrParams params, SolrQueryRequest req) { return new LuceneQParser(qstr, localParams, params, req); } }
public Query parse() throws ParseException { String qstr = getString(); String defaultField = getParam(CommonParams.DF); if (defaultField==null) { defaultField = getReq().getSchema().getDefaultSearchFieldName(); } lparser = new SolrQueryParser(this, defaultField); // these could either be checked & set here, or in the SolrQueryParser constructor String opParam = getParam(QueryParsing.OP); if (opParam != null) { lparser.setDefaultOperator("AND".equals(opParam) ? QueryParser.Operator.AND : QueryParser.Operator.OR); } else { // try to get default operator from schema QueryParser.Operator operator = getReq().getSchema().getSolrQueryParser(null).getDefaultOperator(); lparser.setDefaultOperator(null == operator ? QueryParser.Operator.OR : operator); } return lparser.parse(qstr); }
@Override public SortSpec getSort(boolean useGlobal) throws ParseException { SortSpec sort = super.getSort(useGlobal); if (sortStr != null && sortStr.length()>0 && sort.getSort()==null) { Sort oldSort = QueryParsing.parseSort(sortStr, getReq().getSchema()); if( oldSort != null ) { sort.sort = oldSort; } } return sort; }
public Query parse() throws ParseException { // handle legacy "query;sort" syntax if (getLocalParams() == null) { String qstr = getString(); sortStr = getParams().get(CommonParams.SORT); if (sortStr == null) { // sort may be legacy form, included in the query string List<String> commands = StrUtils.splitSmart(qstr,';'); if (commands.size() == 2) { qstr = commands.get(0); sortStr = commands.get(1); } else if (commands.size() == 1) { // This is need to support the case where someone sends: "q=query;" qstr = commands.get(0); } else if (commands.size() > 2) { throw new SolrException(SolrException.ErrorCode.BAD_REQUEST, "If you want to use multiple ';' in the query, use the 'sort' param."); } } setString(qstr); } return super.parse(); }