Hello!

A few weeks back you removed the hook_luceneapi_facet_values() function (http://drupalcode.org/viewvc/drupal/contributions/modules/luceneapi/cont...); I was wondering why this happened, and what the preferred method is now for specifying options for facets that render as select menus or checkboxes.

I've been looking over the source code trying to figure out a workable solution; it seems like if the facet array (returned by hook_luceneapi_facet) could specify an 'options' or 'values' array (in fact, based on http://drupal.org/node/502498#comment-1806846 it looks like it used to have this?), that array could be used to populate the form field easily enough. However, there are performance implications to doing this if it isn't necessary …which is the problem I thought hook_luceneapi_facet_values() was there to solve.

In any case, is there a way to do this with the current release candidate?

Thanks!
Adam

Comments

cpliakas’s picture

Category: feature » support

Hi Adam.

Thanks for the post. I ended up removing hook_luceneapi_facet_values() for performance reasons. It didn't make sense that all possible values had to be loaded when the facet was built. For example, lets say we have a vocabulary with 1000 taxonomy terms. The way that the old system worked was that a user would execute a search, all possible values were loaded via hook_luceneapi_facet_values(), and then the values were filtered down depending on whether they existed in the search results. If only 3 terms were available after the search, all 1000 would still have to be loaded at some point.

The new system starts with a clean slate, and then the available values are calculated from the search results. Sticking with the example above, a user executes a search, then search Lucene API determines that 3 taxonomy terms are available from the results given, and then the IDs returned by the index are converted to human readable values via hook_luceneapi_postrender_alter(). This has the benefit of only having to load the names of the 3 taxonomy terms as opposed to all 1000.

For a working example, check out the luceneapi_node_luceneapi_postrender_alter() function in the contrib/luceneapi_node/luceneapi_node.module file. To answer your question about how to populate the values for select menus and checkboxes, see how the fieldset realm builds these items in that function. The current method isn't as simple as having the values pre-populated in a hook_luceneapi_facet_values() implementation, but it encourages loading only the data that is needed. Internally, it also simplifies some things in various aspects of the facet API.

Hope this helps,
Chris

cpliakas’s picture

Status: Active » Closed (fixed)

Closing after 2 weeks of inactivity.