private void addTreeFieldsToFacets(ResponseBuilder rb) throws SyntaxError { String[] ftFields = rb.req.getParams().getParams(FACET_TREE_FIELD); if (ftFields == null || ftFields.length == 0) { LOGGER.warn("No facet tree fields specified - ignoring facet trees"); } else { // Take a modifiable copy of the incoming params ModifiableSolrParams params = new ModifiableSolrParams(rb.req.getParams()); // Put the original facet fields (if any) into a Set Set<String> facetFields = new LinkedHashSet<>(); if (params.getParams(FacetParams.FACET_FIELD) != null) { facetFields.addAll(Arrays.asList(params.getParams(FacetParams.FACET_FIELD))); } // Add the facet tree fields for (String ftField : ftFields) { // Parse the facet tree field, so we only add the field value, // rather than the whole string (ensure it's unique) facetFields.add(QueryParsing.getLocalParams(ftField, params).get(QueryParsing.V)); } // Add the (possibly) new facet fields params.set(FacetParams.FACET_FIELD, facetFields.toArray(new String[facetFields.size()])); // Re-set the params in the request rb.req.setParams(params); } }
public FacetBase(ResponseBuilder rb, String facetType, String facetStr) { this.facetType = facetType; this.facetStr = facetStr; try { this.localParams = QueryParsing.getLocalParams(facetStr, rb.req.getParams()); } catch (ParseException e) { throw new SolrException(SolrException.ErrorCode.BAD_REQUEST, e); } this.facetOn = facetStr; this.key = facetStr; if (localParams != null) { // remove local params unless it's a query if (!facetType.equals(FacetParams.FACET_QUERY)) { facetOn = localParams.get(CommonParams.VALUE); key = facetOn; } key = localParams.get(CommonParams.OUTPUT_KEY, key); } }
void parseParams(String type, String param) throws ParseException, IOException { localParams = QueryParsing.getLocalParams(param, req.getParams()); base = docs; facetValue = param;
/** Create a <code>QParser</code> to parse <code>qstr</code>, * assuming that the default query type is <code>defaultType</code>. * The query type may be overridden by local parameters in the query * string itself. For example if defaultType=<code>"dismax"</code> * and qstr=<code>foo</code>, then the dismax query parser will be used * to parse and construct the query object. However * if qstr=<code>{!prefix f=myfield}foo</code> * then the prefix query parser will be used. */ public static QParser getParser(String qstr, String defaultType, SolrQueryRequest req) throws ParseException { SolrParams localParams = QueryParsing.getLocalParams(qstr, req.getParams()); String type; if (localParams == null) { type = defaultType; } else { String localType = localParams.get(QueryParsing.TYPE); type = localType == null ? defaultType : localType; qstr = localParams.get("v"); } type = type==null ? QParserPlugin.DEFAULT_QTYPE : type; QParserPlugin qplug = req.getCore().getQueryPlugin(type); return qplug.createParser(qstr, localParams, req.getParams(), req); }