Apachesolr search results Facet Filter by date range I am using apache solr search with my drupal 6 website and seek a modification in the facets being displayed.

Instead of the yearly facets like this:



to somewhat like this:

last hour
last 24 hours
last week
last month
last year

I found http://searchhub.org/dev/2012/02/23/date-math-now-and-filter-queries/  saying that i can use fq=date:[NOW/DAY-7DAYS TO NOW/DAY+1DAY] in a custom module of my own to do this.

I tried this in my own module and figured out that its the $fq variable of apachesolr.module that should be overriden to achieve this.

I dont think I was able to use it successfully.

Can someone please tell me the exact function and variable to override.
If i clearly understand you will have to use facets date.

And using Solr there's a issue where you cannot do multiple facets on the same field in the same query... This issue is now marked as fixed Solr backlog but the release is not ready yet i believe last time i checked. In my case since the fixed was not ready i created in the schema new field that are copyfields and i do the appropriate query.

Therefore you will have something like that :

Last hour

f.date1.facet.range.start=NOW-1HOUR&amp;f.date1.facet.range.end=NOW&amp;f.date1.facet.range.gap=+1HOUR&amp;

Last 24 hours

f.date2.facet.range.start=NOW-24HOUR&amp;f.date2.facet.range.end=NOW&amp;f.date2.facet.range.gap=+24HOUR&amp;

Last 48 hours

f.date3.facet.range.start=NOW-48HOUR&amp;f.date3.facet.range.end=NOW&amp;f.date3.facet.range.gap=+48HOUR&amp;

Last Week

f.date4.facet.range.start=NOW-7DAY&amp;f.date4.facet.range.end=NOW&amp;f.date4.facet.range.gap=+7DAY&amp;

facet.range=date&amp;facet.range=date2&amp;facet.range=date3&amp;facet.range=date4

Hi hope that helps you!!! Cuz i've look so long to figured out myself ;)