Unlike the typical date format in Apache Solr, it supports friendlier date specifications. That is you can form queries like q=field:[2000-11-01 TO 2014-12-01] or q=field:2000-11. It supports indexing a date range in a single field.
Filter queriesThe fq parameter defines a query that can be used to restrict the superset of documents that can be returned, without influencing score. The fq parameterized queries are cached independent of the main query.
The default value is 0 . In other words, by default, Solr returns results without an offset, beginning where the results themselves begin.
If you want to get last week publications you can do somehting like:
&fq=published_date:[NOW-7DAY/DAY TO NOW]
But if you want a concrete date you must do it in the SOLR date format:
&fq=published_date:[2013-07-17T00:00:00Z TO NOW]
Last but not least.
[ ]
for inclusive ranges{ }
for exclusive ranges[ }
for inclusive - exclusive and vice versa { ]
I hope that helps
The simplest form of Solr date is the keyword 'NOW' which refers to the current date and time. It is case sensitive in Solr, but the Lucid query parser will permit it to be in any case. 'NOW' can be used either if no explicit date or date math is specified, or it can be used if date math is specified without an explicit date.
An explicit date is written in Solr using a format based on ISO 8601, which consists of a string of the form yyyy-mm-ddThh:mm:ss.mmmZ, where 'yyyy' is the four-digit year, the first 'mm' is the two-digit month, 'dd' is the two-digit day, 'T' is the mandatory literal letter 'T' to indicate that time follows, 'hh' is the two-digit hours ('00' to '23'), the second 'mm' is the two-digit minutes ('00' to '59'), 'ss' is the two-digit seconds ('00' to '59'), optionally '.mmm' is the three-digit milliseconds preceded by a period, and 'Z' is the mandatory literal letter 'Z' to indicate that the time is UTC ('Zulu'). The millisecond portion, including its leading period, is optional. Trailing zeros are not required for milliseconds.
For example:
2008-01-01T00:00:00Z
2008-01-01T00:00:00
2008-01-01T00:00 same as [2008-01-01T00:00:00Z TO 2008-01-01T00:00:59Z]
2008-01-01T00: same as [2008-01-01T00:00:00Z TO 2008-01-01T00:59:59Z]
2008-01-01T same as [2008-01-01T00:00:00Z TO 2008-01-01T23:59:59Z]
2008-01-01 same as [2008-01-01T00:00:00Z TO 2008-01-01T23:59:59Z]
2008-01 same as [2008-01-01T00:00:00Z TO 2008-01-31T23:59:59Z]
2008 same as [2008-01-01T00:00:00Z TO 2008-12-31T23:59:59Z]
Credit to Solr Documentation
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With