/** * Returns the resulting query from this QParser, calling parse() only the * first time and caching the Query result. * * @throws ParseException */ public Query getQuery() throws ParseException { if (query==null) { query=parse(); } return query; }
protected Query getAlternateUserQuery(SolrParams solrParams) throws ParseException { String altQ = solrParams.get(DisMaxParams.ALTQ); if (altQ != null) { QParser altQParser = subQuery(altQ, null); return altQParser.parse(); } else { throw new SolrException(SolrException.ErrorCode.BAD_REQUEST, "missing query string"); } }
protected void addBoostFunctions(BooleanQuery query, SolrParams solrParams) throws ParseException { String[] boostFuncs = solrParams.getParams(DisMaxParams.BF); if (null != boostFuncs && 0 != boostFuncs.length) { for (String boostFunc : boostFuncs) { if (null == boostFunc || "".equals(boostFunc)) continue; Map<String, Float> ff = SolrPluginUtils.parseFieldBoosts(boostFunc); for (String f : ff.keySet()) { Query fq = subQuery(f, FunctionQParserPlugin.NAME).parse(); Float b = ff.get(f); if (null != b) { fq.setBoost(b); } query.add(fq, BooleanClause.Occur.SHOULD); } } } }
public Query parse() throws ParseException { b = localParams.get(BOOSTFUNC); baseParser = subQuery(localParams.get(QueryParsing.V), null); Query q = baseParser.parse(); if (b == null) return q; Query bq = subQuery(b, FunctionQParserPlugin.NAME).parse(); if (bq instanceof FunctionQuery) { vs = ((FunctionQuery)bq).getValueSource(); } else { vs = new QueryValueSource(bq, 0.0f); } return new BoostedQuery(q, vs); }
return (FunctionQuery)(QParser.getParser(func,"func",new LocalSolrQueryRequest(core,new HashMap())).parse());
for (String qs : boostParams) { if (qs.trim().length() == 0) continue; Query q = subQuery(qs, null).parse(); boostQueries.add(q);
QParser qParser = QParser.getParser(corpusFilterQuery, null, req); try { filterQueries.add(qParser.parse()); } catch (SyntaxError e) { throw new SolrException(SolrException.ErrorCode.BAD_REQUEST, e);
QParser qParser = QParser.getParser(corpusFilterQuery, null, req); try { filterQueries.add(qParser.parse()); } catch (SyntaxError e) { throw new SolrException(SolrException.ErrorCode.BAD_REQUEST, e);
public Query parse() throws ParseException { funcStr = localParams.get(QueryParsing.V, null); Query funcQ = subQuery(funcStr, FunctionQParserPlugin.NAME).parse(); if (funcQ instanceof FunctionQuery) { vs = ((FunctionQuery)funcQ).getValueSource(); } else { vs = new QueryValueSource(funcQ, 0.0f); } String l = localParams.get("l"); String u = localParams.get("u"); boolean includeLower = localParams.getBool("incl",true); boolean includeUpper = localParams.getBool("incu",true); // TODO: add a score=val option to allow score to be the value ValueSourceRangeFilter rf = new ValueSourceRangeFilter(vs, l, u, includeLower, includeUpper); SolrConstantScoreQuery csq = new SolrConstantScoreQuery(rf); return csq; } };