Looking at the hooks altering the search results- in 6.x we had a lame "namespace" parameter.

In 7.x we need to be able to load the relevant search environment or look at the query parameters, so we should at least pass in the $query object to these hooks.

CommentFileSizeAuthor
#1 1341854-1.patch1.9 KBpwolanin

Comments

pwolanin’s picture

Status: Active » Needs review
StatusFileSize
new1.9 KB
pwolanin’s picture

Title: Pass the query into hooks altering search results » Pass the query object into hooks altering search results
Status: Needs review » Fixed

committed

pwolanin’s picture

Does this make sense, or should we just pass the environment ID.

Here's an example of how I'm trying to use it in the multisite patch:

/**
 * Implements hook_apachesolr_query_alter().
 */
function apachesolr_multisitesearch_apachesolr_query_alter(DrupalSolrQueryInterface $query) {
  $env_id = $query->solr('getId');
  $multisite = apachesolr_environment_variable_get($env_id, 'multisitesearch');
  if (empty($multisite)) {
    // Limit single site searchs via the site hash.
    $query->addFilter('hash', apachesolr_site_hash());
  }
}

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.