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.

-0009 – The year 10 BC. A 0 in the year position is 0 AD, and is also considered 1 BC.<br />

[2000-11-01 TO 2014-12-01] – The specified date range at a day resolution.<br />

[2014 TO 2014-12-01] – From the start of 2014 till the end of the first day of December.<br />

[* TO 2014-12-01] – From the earliest representable time thru till the end of 2014-12-01.<br />

Limitations: The range syntax doesn't support embedded date math. If you specify a date instance supported by<br />

TrieDateField with date math truncating it, like NOW/DAY, you still get the first millisecond of that day, not the<br />

entire day's range. Exclusive ranges (using { & }) work in queries but not for indexing ranges.<br />

Date Math<br />

<strong>Solr</strong>'s date field types also supports date math expressions, which makes it easy to create times relative to fixed<br />

moments in time, include the current time which can be represented using the special value of " NOW".<br />

Date Math Syntax<br />

Date math expressions consist either adding some quantity of time in a specified unit, or rounding the current<br />

time by a specified unit. expressions can be chained and are evaluated left to right.<br />

For example: this represents a point in time two months from now:<br />

NOW+2MONTHS<br />

This is one day ago:<br />

NOW-1DAY<br />

A slash is used to indicate rounding. This represents the beginning of the current hour:<br />

NOW/HOUR<br />

The following example computes (with millisecond precision) the point in time six months and three days into the<br />

future and then rounds that time to the beginning of that day:<br />

NOW+6MONTHS+3DAYS/DAY<br />

Note that while date math is most commonly used relative to NOW it can be applied to any fixed moment in time<br />

as well:<br />

1972-05-20T17:33:18.772Z+6MONTHS+3DAYS/DAY<br />

Request Parameters That Affect Date Math<br />

NOW<br />

The NOW parameter is used internally by <strong>Solr</strong> to ensure consistent date math expression parsing across multiple<br />

nodes in a distributed request. But it can be specified to instruct <strong>Solr</strong> to use an arbitrary moment in time (past or<br />

future) to override for all situations where the the special value of " NOW" would impact date math expressions.<br />

It must be specified as a (long valued) milliseconds since epoch<br />

Example:<br />

q=solr&fq=start_date:[* TO NOW]&NOW=1384387200000<br />

TZ<br />

By default, all date math expressions are evaluated relative to the UTC TimeZone, but the TZ parameter can be<br />

specified to override this behaviour, by forcing all date based addition and rounding to be relative to the specified<br />

time zone.<br />

For example, the following request will use range faceting to facet over the current month, "per day" relative<br />

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

58

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

Saved successfully!

Ooh no, something went wrong!