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

aufumy - November 27, 2008 - 01:21

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

paul.lovvik - January 22, 2009 - 05:15
Status:active» needs review

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.

AttachmentSize
search.patch 10.41 KB

#3

pwolanin - January 23, 2009 - 23:39

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

JacobSingh - January 24, 2009 - 04:23

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.

AttachmentSize
active_filters_ux.diff 11.27 KB

#5

JacobSingh - January 25, 2009 - 03:05

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

AttachmentSize
apachesolr_admin_links.diff 11.82 KB

#6

JacobSingh - January 25, 2009 - 03:07

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

Re-rolled:

AttachmentSize
apachesolr_admin_links.diff 11.74 KB

#7

pwolanin - January 26, 2009 - 16:43
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.

#8

pwolanin - January 26, 2009 - 16:55

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

#9

pwolanin - January 26, 2009 - 16:56

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

#10

pwolanin - January 26, 2009 - 17:07

I'm re-working this patch now.

#11

pwolanin - January 26, 2009 - 19:15

not working yet, but getting there.

AttachmentSize
enabled-facets-339467-11.patch 32.7 KB

#12

pwolanin - January 26, 2009 - 20:37

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

AttachmentSize
enabled-facets-339467-12.patch 36.11 KB

#13

pwolanin - January 26, 2009 - 22:31
Status:needs work» needs review

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);

AttachmentSize
enabled-facets-339467-13.patch 48.81 KB

#14

pwolanin - January 26, 2009 - 22:39

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

#15

pwolanin - January 26, 2009 - 22:52
Category:feature request» task
Priority:normal» critical

#16

pwolanin - January 26, 2009 - 23:33
Status:needs review» fixed

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

#17

pwolanin - February 2, 2009 - 14:25
Status:fixed» closed
 
 

Drupal is a registered trademark of Dries Buytaert.