11.05.2016 Views

Apache Solr Reference Guide Covering Apache Solr 6.0

21SiXmO

21SiXmO

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

it includes parentheses. For example:<br />

_val_:myfield<br />

_val_:"recip(rord(myfield),1,2,3)"<br />

The <strong>Solr</strong> Query Parser offers nested query support for any type of query parser (via QParserPlugin).<br />

Quotes are often necessary to encapsulate the nested query if it contains reserved characters. For<br />

example:<br />

_query_:"{!dismax qf=myfield}how now brown cow"<br />

Although not technically a syntax difference, note that if you use the <strong>Solr</strong> TrieDateField type, any queries on<br />

those fields (typically range queries) should use either the Complete ISO 8601 Date syntax that field supports, or<br />

the DateMath Syntax to get relative dates. For example:<br />

timestamp:[* TO NOW]<br />

createdate:[1976-03-06T23:59:59.999Z TO *]<br />

createdate:[1995-12-31T23:59:59.999Z TO 2007-03-06T00:00:00Z]<br />

pubdate:[NOW-1YEAR/DAY TO NOW/DAY+1DAY]<br />

createdate:[1976-03-06T23:59:59.999Z TO 1976-03-06T23:59:59.999Z+1YEAR]<br />

createdate:[1976-03-06T23:59:59.999Z/YEAR TO 1976-03-06T23:59:59.999Z]<br />

TO must be uppercase, or <strong>Solr</strong> will report a 'Range Group' error.<br />

Function Queries<br />

Function queries enable you to generate a relevancy score using the actual value of one or more numeric fields.<br />

Function queries are supported by the DisMax, Extended DisMax, and standard query parsers.<br />

Function queries use functions. The functions can be a constant (numeric or string literal), a field, another<br />

function or a parameter substitution argument. You can use these functions to modify the ranking of results for<br />

users. These could be used to change the ranking of results based on a user's location, or some other<br />

calculation.<br />

Function query topics covered in this section:<br />

Using Function Query<br />

Available Functions<br />

Example Function Queries<br />

Sort By Function<br />

Related Topics<br />

Using Function Query<br />

Functions must be expressed as function calls (for example, sum(a,b) instead of simply a+b).<br />

There are several ways of using function queries in a <strong>Solr</strong> query:<br />

Via an explicit QParser that expects function arguments, such func or frange . For example:<br />

q={!func}div(popularity,price)&fq={!frange l=1000}customer_ratings<br />

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

269

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

Saved successfully!

Ooh no, something went wrong!