I have a project where the client requested that users be allowed to search within custom date ranges, which I provided by adding a custom form that generates the proper SOLR query. This is all well and good, but it turns out that date facet blocks were not constructed to work with date ranges except for those that it itself provides (exactly one year, exactly one month, exactly one day, etc.). For example, if you do a search over two years, the date facet block will only provide months during the first year, instead of providing the two years as drilldown options.
So here's a patch that rewrites some of the date facet code to allow users to support custom date ranges. This doesn't change any of the out-of-the-box functionality at all -- date facet blocks still continue to work as they did before. It simply allows more advanced users to add custom date range searches if desired, with the date facet block acting as you would expect.
To test this, you can:
1) Ensure that the default date drilldown works as before.
2) Manually modify the date range query to test custom date ranges in which you have content. E.g., if you had a CCK date field: filters=tds_cck_field_date:[1995-03-01T00:00:00Z TO 1996-12-19T00:00:00Z] -- which isn't something the facet block will ever give you. In this case, the facet block should start with year options, such as:
1995 (3)
1996 (2)
| Comment | File | Size | Author |
|---|---|---|---|
| #9 | date-widget.png | 285.53 KB | cpliakas |
| #5 | 830654_5_solr_date_range.patch | 6.16 KB | scor |
| #2 | apachesolr_custom_range_drilldown.patch | 8.16 KB | mcarbone |
| apachesolr_custom_range_drilldown.patch | 8.12 KB | mcarbone |
Comments
Comment #1
mcarbone commentedNeed to re-roll for dev branch.
Comment #2
mcarbone commentedRe-rolled for dev branch.
Comment #3
jpmckinney commentedAdd tag
Comment #4
jpmckinney commentedComment #5
scor commentedhere is a port of the patch in #2 to D7. works like a charm.
Comment #6
pwolanin commentedpostponed since we are trying to move this sort of stuff out to the Facet API module.
Comment #7
pwolanin commentedComment #8
cpliakas commentedComment #9
cpliakas commentedLooking into this further, I think there is a wide use case for this. The attached screenshot shows Google's date range facet that Facet API should be able to achieve through the GUI. The GUI should allow for a configurable list of ranges that can be added and sorted by a site administrator. Will attach wireframes with my ideas.
From a technical standpoint, this would require a query type plugin for Apache Solr and a display widget that supports custom ranges. In addition, we will need to re-implement the widget requirements system that existed in the 6.x-1.x branch. An issue has been posted at #1176814: Re-implement the widget requirements system and is assigned to myself.
Assigning this issue to myself as well because the dependencies required to achieve this functionality are critical in terms of the low-level architecture of this module.
Comment #10
cpliakas commentedPost by @pwolanin at http://drupal.org/node/1132744#comment-4550722
Comment #11
dynamicdan commentedI stumbled across this issue but would expect a slightly different implementation than buckets.
Is it possible to allow inputs for min and max dates? My use case is selecting years. Eg. 1920 - 1940.
Perhaps a simple theme/alter approach would allow basically the same input but different output to the GUI?
Comment #12
davidseth commentedRegarding #9, where is this at? I am more than happy to help on this but some pointers would be great!
Comment #13
cpliakas commentedAdding to the Contrib component, which means that I am looking for this functionality to be added outside of this module in a separate contrib.
Comment #14
cpliakas commentedChanging to a feature request.
Comment #15
cpliakas commentedSandbox project started at http://drupal.org/sandbox/cpliakas/1827540 to solve this use case.
Comment #16
cpliakas commentedMarking as fixed due to beta1 release of the Date Facets module.