= Local Parameters in Queries
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements.  See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership.  The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
// with the License.  You may obtain a copy of the License at
//
//   http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied.  See the License for the
// specific language governing permissions and limitations
// under the License.

Local parameters are arguments in a Solr request that are specific to a query parameter.

Local parameters provide a way to add meta-data to certain argument types such as query strings. (In Solr documentation, local parameters are sometimes referred to as LocalParams.)

Local parameters are specified as prefixes to arguments. Take the following query argument, for example:

`q=solr rocks`

We can prefix this query string with local parameters to provide more information to the Standard Query Parser. For example, we can change the default operator type to "AND" and the default field to "title":

`q={!q.op=AND df=title}solr rocks`

These local parameters would change the query to require a match on both "solr" and "rocks" while searching the "title" field by default.

== Basic Syntax of Local Parameters

To specify a local parameter, insert the following before the argument to be modified:

* Begin with `{!`

* Insert any number of key=value pairs separated by white space

* End with `}` and immediately follow with the query argument

You may specify only one local parameters prefix per 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 local parameter 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`

If no "type" is specified (either explicitly or implicitly) then the <<the-standard-query-parser.adoc#the-standard-query-parser,lucene parser>> is used by default. Thus

`fq={!df=summary}solr rocks`

is equivalent to:

`fq={!type=lucene df=summary}solr rocks`

== Specifying the Parameter Value with the v Key

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, lets you 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`
