11.05.2016 Views

Apache Solr Reference Guide Covering Apache Solr 6.0

21SiXmO

21SiXmO

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

enter:<br />

http://localhost:8983/solr/collection_name/select?q=*:*&sort=dist(2, point1, point2)<br />

desc<br />

Sort by function also supports pseudo-fields: fields can be generated dynamically and return results as though it<br />

was normal field in the index. For example,<br />

&fl=id,sum(x, y),score<br />

would return:<br />

foo<br />

40<br />

0.343<br />

Related Topics<br />

FunctionQuery<br />

Local Parameters in Queries<br />

Local parameters are arguments in a <strong>Solr</strong> request that are specific to a query parameter. Local parameters<br />

provide a way to add meta-data to certain argument types such as query strings. (In <strong>Solr</strong> documentation, local<br />

parameters are sometimes referred to as LocalParams.)<br />

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

q=solr rocks<br />

We can prefix this query string with local parameters to provide more information to the Standard Query Parser.<br />

For example, we can change the default operator type to "AND" and the default field to "title":<br />

q={!q.op=AND df=title}solr rocks<br />

These local parameters would change the query to require a match on both "solr" and "rocks" while searching<br />

the "title" field by default.<br />

Basic Syntax of Local Parameters<br />

To specify a local parameter, insert the following before the argument to be modified:<br />

Begin with {!<br />

Insert any number of key=value pairs separated by white space<br />

End with } and immediately follow with the query argument<br />

You may specify only one local parameters prefix per argument. Values in the key-value pairs may be quoted via<br />

single or double quotes, and backslash escaping works within quoted strings.<br />

Query Type Short Form<br />

If a local parameter value appears without a name, it is given the implicit name of "type". This allows short-form<br />

representation for the type of query parser to use when parsing a query string. Thus<br />

q={!dismax qf=myfield}solr rocks<br />

<strong>Apache</strong> <strong>Solr</strong> <strong>Reference</strong> <strong>Guide</strong> <strong>6.0</strong><br />

278

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!