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.

UTC:<br />

http://localhost:8983/solr/my_collection/select?q=*:*&facet.range=my_date_field&face<br />

t=true&facet.range.start=NOW/MONTH&facet.range.end=NOW/MONTH%2B1MONTH&facet.range.ga<br />

p=%2B1DAY<br />

0<br />

0<br />

0<br />

0<br />

0<br />

0<br />

0<br />

...<br />

While in this example, the "days" will be computed relative to the specified time zone - including any applicable<br />

Daylight Savings Time adjustments:<br />

http://localhost:8983/solr/my_collection/select?q=*:*&facet.range=my_date_field&face<br />

t=true&facet.range.start=NOW/MONTH&facet.range.end=NOW/MONTH%2B1MONTH&facet.range.ga<br />

p=%2B1DAY&TZ=America/Los_Angeles<br />

0<br />

0<br />

0<br />

0<br />

0<br />

0<br />

0<br />

...<br />

More DateRangeField Details<br />

DateRangeField is almost a drop-in replacement for places where TrieDateField is used. The only<br />

difference is that <strong>Solr</strong>'s XML or <strong>Solr</strong>J response formats will expose the stored data as a String instead of a Date.<br />

The underlying index data for this field will be a bit larger. Queries that align to units of time a second on up<br />

should be faster than TrieDateField, especially if it's in UTC. But the main point of DateRangeField as it's name<br />

suggests is to allow indexing date ranges. To do that, simply supply strings in the format shown above. It also<br />

supports specifying 3 different relational predicates between the indexed data, and the query range: Intersect<br />

s (default), Contains, Within. You can specify the predicate by querying using the op local-params parameter<br />

like so:<br />

fq={!field f=dateRange op=Contains}[2013 TO 2018]<br />

In that example, it would find documents with indexed ranges that contain (or equals) the range 2013 thru 2018.<br />

Multi-valued overlapping indexed ranges in a document are effectively coalesced.<br />

For a DateRangeField example use-case and possibly other information, see <strong>Solr</strong>'s community wiki.<br />

Working with Enum Fields<br />

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

59

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

Saved successfully!

Ooh no, something went wrong!