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.

Comments

aufumy’s picture

Sounds good. I do also like the idea of checkboxes on admin page to check which fields to facet;
http://drupal.org/node/281810

paul.lovvik’s picture

Status: Active » Needs review
StatusFileSize
new10.41 KB

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.

pwolanin’s picture

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

JacobSingh’s picture

StatusFileSize
new11.27 KB

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.

JacobSingh’s picture

StatusFileSize
new11.82 KB

Here is another patch (containing #4 as well) which adds a link for admins to the filter configuration screen below each facet block.

JacobSingh’s picture

StatusFileSize
new11.74 KB

Whoops, sorry that patch had some debugging stuff in it.

Re-rolled:

pwolanin’s picture

Status: Needs review » Needs work

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.

pwolanin’s picture

Also, t() strings should not have extra white space in them.

pwolanin’s picture

Also, the node type facet code should be moved out of the framework module.

pwolanin’s picture

I'm re-working this patch now.

pwolanin’s picture

StatusFileSize
new32.7 KB

not working yet, but getting there.

pwolanin’s picture

StatusFileSize
new36.11 KB

starting to work - needed uasort to preserve array keys, etc

pwolanin’s picture

Status: Needs work » Needs review
StatusFileSize
new48.81 KB

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);
pwolanin’s picture

note lots of moving around here - net is only +39 lines thanks to reduced code duplication

pwolanin’s picture

Category: feature » task
Priority: Normal » Critical
pwolanin’s picture

Status: Needs review » Fixed

committed to 6.x - hopefully I didn't miss anything

pwolanin’s picture

Status: Fixed » Closed (fixed)