@Override public Query parse() throws SyntaxError { if (qstr == null || qstr.length()==0) return null; String defaultField = getParam(CommonParams.DF); if (defaultField==null) { defaultField = getReq().getSchema().getDefaultSearchFieldName(); } xmlParser = new XmlQueryParser(defaultField, new StandardAnalyzer(req.getCore().getSolrConfig().luceneMatchVersion)); try { return xmlParser.parse(new ByteArrayInputStream(qstr.getBytes(Charset.forName("utf-8")))); } catch (ParserException e) { throw new SyntaxError (e); } }
String defaultSearchField = request.getSchema().getDefaultSearchFieldName(); fields = null == defaultSearchField ? new String[]{} : new String[]{defaultSearchField};
/** * Constructs a SolrQueryParser using the schema to understand the * formats and datatypes of each field. Only the defaultSearchField * will be used from the IndexSchema (unless overridden), * <solrQueryParser> will not be used. * * @param schema Used for default search field name if defaultField is null and field information is used for analysis * @param defaultField default field used for unspecified search terms. if null, the schema default field is used * @see IndexSchema#getDefaultSearchFieldName() */ public SolrQueryParser(IndexSchema schema, String defaultField) { super(defaultField == null ? schema.getDefaultSearchFieldName() : defaultField, schema.getQueryAnalyzer()); this.schema = schema; this.parser = null; this.defaultField = defaultField; setLowercaseExpandedTerms(false); setEnablePositionIncrements(true); checkAllowLeadingWildcards(); }
analysisRequest.addFieldName(req.getSchema().getDefaultSearchFieldName());
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); }
finfo.add("uniqueKeyField", null == uniqueField ? null : uniqueField.getName()); finfo.add("defaultSearchField", schema.getDefaultSearchFieldName()); finfo.add("types", types); return finfo;