I recently had a client request that we develop a way to limit results in searches to only the current domain in a multi-domain setup using Domain Access. My fix was to leverage this module with only a bit of extra code in an additional custom module:

/**
 * Implements hook_apachesolr_prepare_query.
 */
function mymodule_apachesolr_prepare_query(&$query, &$params, $caller) {
  if (module_exists('domain_solr') && $caller == 'apachesolr_search') {
    global $_domain;
    $query->add_filter('im_domain_id', $_domain['domain_id']);
  }
}

I'm a bit torn as to whether this would be best as its own separate module, or as a feature of this one. Since the main purpose of this module is to make the facet block, and this code actually implies that you don't want the block enabled (you just want results filtered automatically), I'm not sure which path to go.

What do you think? It would be as easy as replacing the module_exists() call with a variable_get() that's set somewhere in the admin to say "Do you want all search results limited to just the current domain?"

Comments

shaneonabike’s picture

Actually I rolled this into a patch for the code since I think it's fairly useful and needed for my client. As well I included some functionality for apachesolr views although I feel that this is fairly limited and not working perfectly (in general for the module that is).