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} ]
&low=50
&high=100

One can also specify default values:

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

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

References

This page was adapted from http://yonik.com/solr-query-parameter-substitution/