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)

Comments

mcarbone’s picture

Assigned: Unassigned » mcarbone
Status: Needs review » Needs work

Need to re-roll for dev branch.

mcarbone’s picture

Version: 6.x-2.0-beta2 » 6.x-2.x-dev
Assigned: mcarbone » Unassigned
Status: Needs work » Needs review
StatusFileSize
new8.16 KB

Re-rolled for dev branch.

jpmckinney’s picture

Issue tags: +apachesolr_date

Add tag

jpmckinney’s picture

Title: Support date facet drilldown when using custom date ranges » Support custom date ranges
Version: 6.x-2.x-dev » 7.x-1.x-dev
scor’s picture

StatusFileSize
new6.16 KB

here is a port of the patch in #2 to D7. works like a charm.

pwolanin’s picture

Status: Needs review » Postponed

postponed since we are trying to move this sort of stuff out to the Facet API module.

pwolanin’s picture

Project: Apache Solr Search » Facet API
Version: 7.x-1.x-dev »
Status: Postponed » Needs work
cpliakas’s picture

Version: » 7.x-1.x-dev
cpliakas’s picture

Title: Support custom date ranges » Implement a date widget for custom date ranges
Assigned: Unassigned » cpliakas
Category: feature » task
Priority: Normal » Major
Status: Needs work » Active
Issue tags: -apachesolr_date
StatusFileSize
new285.53 KB

Looking 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.

cpliakas’s picture

Post by @pwolanin at http://drupal.org/node/1132744#comment-4550722

The google date-range widget is pretty close to the non-JS fallback I started implementing for a general range filter here: http://drupal.org/sandbox/cpliakas/1160920

One might even imagine a slider for limiting e.g. at most X days ago

In any case, replication the google format of the date wiget ought to be pretty easy, and that's potentially something that could be used in the fieldset/form pre-search as well as after a search. On thing google doesn't have there which would be cool is to do facet queries and actually show the # of results in each of the options.

dynamicdan’s picture

I 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?

davidseth’s picture

Regarding #9, where is this at? I am more than happy to help on this but some pointers would be great!

cpliakas’s picture

Component: Code » Contrib

Adding to the Contrib component, which means that I am looking for this functionality to be added outside of this module in a separate contrib.

cpliakas’s picture

Category: task » feature

Changing to a feature request.

cpliakas’s picture

Sandbox project started at http://drupal.org/sandbox/cpliakas/1827540 to solve this use case.

cpliakas’s picture

Status: Active » Fixed

Marking as fixed due to beta1 release of the Date Facets module.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.