Parameter Substitution or Macro Expansion is a request templating mechanism that works for search requests across all request parameters, including any JSON body that may be passed via the JSON Request API.

The macro expansion is done at the same point in time that default parameters are applied (i.e. when the request reaches the correct request handler). This means that request handler defaults, appends, and invariants configured for the handler may reference request parameters, and vice-versa.

Here’s a very simple example of parameterizing a range query in lucene/solr syntax:

q=popularity:[ ${low} TO ${high} ]

One can also specify default values:

q=popularity:[ ${low:0} TO ${high:100} ]
Substitutions can themselves contain further macro expansions:
&pop_query=${pop_field}:[ ${low} TO ${high} ] AND inStock:true

If you want to disable macro expansion, simply pass expandMacros=false as a request parameter.


This page was adapted from