Solr's DateRangeField, How Does It Perform?
I have to credit David Smiley as co-author here. First of all, he's largely responsible for the spatial functionality and second he's been very generous explaining some details here. Mistakes are my responsibility of course. Solr has had a new DateRangeField for quite some time (since 5.0, see SOLR-6103. DateRangeFields are based on more of the magic of Solr Spatial and allow some very interesting ways of working with dates. Here are a couple of references to get you started. Working with dates, Solr Reference Guide Spatial for Time Durations
About DateRangeField:
- It is a fieldType
- It supports friendlier date specifications, that is you can form queries like
q=field:[2000-11-01 TO 2014-12-01]
orq=field:2000-11
- It supports indexing a
date range
in a single field. For instance a field in a document could be added to a document in SolrJ as solrInputDocument.addField("dateRange", "[2000 TO 2014-05-21]") or in an XML format as<field name="dateRange">[2000 TO 2014-05-21]</field>
- It supports multi-valued date ranges. This has always been a difficult thing to do with Solr/Lucene. To index a range, one had to have two fields, say "date_s" and "date_e". It was straightforward to perform a query that found docs spaning some date, it looked something like
q=date_e:[* TO target] AND date_s:[target TO *]
. This worked fine if the document only had one range, but when two or more ranges were necessary, this approach falls down since if date_s and date_e have multiValued="true", the query above would find the doc if any entry indate_s
was < than target date and anydate_e
was > the target date..
Read full article from Solr's DateRangeField, How Does It Perform?
No comments:
Post a Comment