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

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:

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.


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

is equivalent to

Parameter value

A special key of "v" within local parameters is an alternate way to specify the value of that parameter.

is equivalent to

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.

is equivalent to

LocalParams (last edited 2013-02-23 00:33:24 by HossMan)