A query parser parses a string into an internal Lucene query object, potentially considering request parameters and so-called local-params. Only a few parsers actually do real string parsing; some parsers—like those for geospatial—don't even use the query string. The default query parser is named lucene
, and it has a special leading syntax to switch the parser to another and/or to specify parameters. Here's an example using the dismax
parser along with two local-params and a query string of billy corgan
:
{!dismax qf="a_name^2 a_alias" tie=0.1}billy corgan
There are a few things to know about the local-params syntax:
type
local-param.$
, for example, v=$qq
. This is useful to decompose a larger query, and to define parts of the query in different places between the request and the request handler's configuration.v
can be used to hold the query string as an alternative to it following }
. The query()
function query requires this approach. That will be shown later.tie
parameter in the preceding example.For an interesting example, see the subquery syntax later in the Subqueries section.
Solr includes quite a few different query parsers. In the next section, you'll learn all about lucene
. To process user queries, you should typically use dismax
or edismax
(short for extended-DisMax), which are described afterwards. The other query parsers are for special things, such as geospatial search, also described at the end of this chapter. This book only explores the most useful parsers; for further information, see https://cwiki.apache.org/confluence/display/solr/Query+Syntax+and+Parsing.