I've made a start on handling date arguments and allowting them to work with the apachesolr date facets.

I've attached a patch with my changes from the latest dev release (24th November).

A couple of notes:

At the moment, I have introduced a dependency on the date_api module. Using this saved me a lot of time in handling a nicer date format than the ApacheSolr ones - e.g. 2009-11 - instead of the full ISO from/to range.

I wanted the urls to be tidy when using the date facets drill down. Since this often involves multiple arguments separated by commas, the patch attempts to merge these where possible - e.g. view/2009,2009-11,2009-11-25 simply becomes view/2009-11-25. The code works, but perhaps isn't yet as elegant as it could be.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

smoothify’s picture

Status: Needs work » Active
Maikel’s picture

I applied above patch against the 6.x-1.x-dev version. And am using Apachesolr Search Integration (6.x-2.x-dev) with the following patch (http://drupal.org/node/558160#comment-2755896) applied, that patch makes adding cck date fields possible.

So i added a view, set the date argument (created date) and the block is showing up but it does not work. I see the links, but they link to nothing.
If it is of any help, using the block without a view does work.

What can i be doing wrong? More feedback needed?

ps: Would this patch be a good starting point to add the same functionality for cck date fields/facets?

Anonymous’s picture

subscribe

Hadrien KOHL’s picture

Hi all,

I adapted the code to work on latest dev version.

Cheers,

kenorb’s picture

Status: Needs review » Active
FileSize
6.41 KB

Updated against last CVS HEAD version.
I didn't test it yet.

kenorb’s picture

Status: Active » Needs review
kenorb’s picture

Status: Active » Needs work

This patch should be converted into non date_api dependent. And proper if's.

smoothify’s picture

I will be revisiting this myself soon, as I need this functionality on a site that has been delayed since my first post here.

I agree that we should try and remove the dependency for date_api. My hope when creating the patch was that we could decide exactly what format the date arguments and make sure the direction is clear - but since then I haven't used Solr Views much.

Looking at the patch it seems the main function in use from date_api is arg_range(). So, it should be pretty easy to replicate that functionality into the handler, even if its almost a direct copy.

Equinger’s picture

The patch in #5 cannot be used on the latest dev version. The last "Hunk" does not match up.

mvc’s picture

FileSize
10.31 KB

patch #5 didn't work for me because 'created' and 'changed' weren't included in the list in apachesolr_views_query::part_of_facet_block(), meaning that get_path() didn't call argument_part() to generate the facet links. patch attached against version 6.x-1.x-dev from datestamp 1265932882 (11 Feb 2010). i'm not planning to upgrade my production sites to newer versions of this module unless and until there's a stable release to use, but hopefully this patch will still be applicable to later versions.

i didn't consider replacing the call to arg_range() because that function is nontrivial. date handling in general is complex and i think using date_api here is perfectly reasonable.

kenorb’s picture

Status: Needs work » Needs review
rjbrown99’s picture

You could always leave the dependency, and just roll this into a sub-module that is enabled independently of the main apachesolr_views module. Just an idea to compartmentalize the dependency.

smoothify’s picture

@rjbrown99

I agree with that moving into a submodule would makes sense here, if that route is taken though, something would need to be done about the argument_part function - we would need some kind of hook in there so we could manipulate the argument.

kenorb’s picture

Priority: Normal » Minor
Issue summary: View changes