Skip to end of metadata
Go to start of metadata


LocalParams stands for local parameters: they provide a way to "localize" information about a specific argument that is being sent to Solr. In other words, LocalParams provide a way to add meta-data to certain argument types such as query strings.

LocalParams are expressed as prefixes to arguments to be sent to Solr. For example:

Assume we have the existing query parameter
q=solr rocks
We can prefix this query string with LocalParams to provide more information to the query parser, for example changing the default operator type to "AND" and the default field to "title" for the lucene query parser:
q={!q.op=AND df=title}solr rocks

Basic Syntax

To indicate a LocalParam, the argument is prefixed with curly braces whose contents begin with an exclamation point and include any number of key=value pairs separated by whitespace. So if the original argument is foo, applying LocalParams would look something like {!k1=v1 k2=v2 k3=v3}foo.

There may only be one LocalParams prefix per argument, preventing the need for any escaping of the original argument. Values in the key-value pairs may be quoted via single or double quotes, and backslash escaping works within quoted strings.

q={!type=dismax qf='myfield yourfield'}solr rocks

Query type short-form

If a LocalParams value appears without a name, it is given the implicit name of "type". This allows short-form representation for the type of query parser to use when parsing a query string. Thus
q={!dismax qf=myfield}solr rocks
is equivalent to
q={!type=dismax qf=myfield}solr rocks

Parameter value

A special key of "v" within local parameters is an alternate way to specify the value of that parameter.
q={!dismax qf=myfield}solr rocks
is equivalent to
q={!type=dismax qf=myfield v='solr rocks'}

Parameter dereferencing

Parameter dereferencing or indirection allows one to use the value of another argument rather than specifying it directly. This can be used to simplify queries, decouple user input from query parameters, or decouple front-end GUI parameters from defaults set in solrconfig.xml.
q={!dismax qf=myfield}solr rocks
is equivalent to
q={!type=dismax qf=myfield v=$qq}&qq=solr rocks

  • No labels