centralize/register node facets blocks
pwolanin - November 26, 2008 - 17:05
| Project: | Apache Solr Search Integration |
| Version: | 6.x-1.x-dev |
| Component: | Code |
| Category: | task |
| Priority: | critical |
| Assigned: | Unassigned |
| Status: | closed |
Description
We currently have a performance issue since all possible facets are being requested, not just those needed for the enabled blocks.
In addition, many of the hook_block implementations have a fair amount of duplicate code.
The proposed feature: apachesolr.module will do a hook invocation to find all fields where there is a module that wants to implement a facet block. All blocks would be manged also via apachesolr.module, so individual modules would not have to implement as much code.
Obviously, the individual modules would have to provide callbacks for some of the logic.

#1
Sounds good. I do also like the idea of checkboxes on admin page to check which fields to facet;
http://drupal.org/node/281810
#2
This patch creates a new settings panel that can be used to configure which facets are active. Only the active facets appear on the block configuration page. Also the search url contains only the active facets.
#3
Looks like a good start, but we need to think about whether we want to call the hook fmor apachesolr.module or apachesolr_search.module
#4
This patch address a bug wherein a null is treated as an array in the $form and throws a warning.
It also changes "Facet" to "filter" where exposed to the user and adds some help text.
#5
Here is another patch (containing #4 as well) which adds a link for admins to the filter configuration screen below each facet block.
#6
Whoops, sorry that patch had some debugging stuff in it.
Re-rolled:
#7
I see a significant bug here:
+ foreach($facets['facets'] as $facet => $facet_value) {+ if (!empty($facet_value)) {
$params['facet.field'][] = $facet;
That assumes that the delta is the same as the facet field, which we know is not true. With this code, I thin kwe need:
$params['facet.field'][] = $facet_value;but we shoudl rename these vars for clarity.
#8
Also, t() strings should not have extra white space in them.
#9
Also, the node type facet code should be moved out of the framework module.
#10
I'm re-working this patch now.
#11
not working yet, but getting there.
#12
starting to work - needed uasort to preserve array keys, etc
#13
more rewriting - removes block code duplication.
Also, we had some really odd/bad code:
$items = array_slice($items, 0, ($facet_display_limit == -1 ? NULL : $facet_display_limit));Which meant we were requesting exgtra facets and then throwing them away. I modified the query so that we alsys add a default limit for the # of facets returned.
// Add a default limit for fields where no limit was set.$params['facet.limit'] = variable_get('apachesolr_facet_query_limit_default', 20);
#14
note lots of moving around here - net is only +39 lines thanks to reduced code duplication
#15
#16
committed to 6.x - hopefully I didn't miss anything
#17