Filter to return only one site on Multisite Search tab - Apachesolr_multisitesearch module

Error message

The spam filter installed on this site is currently unavailable. Per site policy, we are unable to accept new submissions until that problem is resolved. Please try resubmitting the form in a couple of minutes.

This module is dependent on the apachesolr_multisitesearch module.

Problem:
Had an apache solr index that contained multiple site indexes. On various sites contained in this index we needed results from one and only one site contained in this index. Also, needed the to rename the default tab.

Resolution:
Create a small module that adds a new hash filter for multisitesearch.

First get the site's hash. To do this utilize drush:

  1. Go to directory (or use drush alias) for site you are wanting to show up.
  2. Run: # drush vget apachesolr_site_hash
  3. Make a note of the returned has code.
  4. Sample code for filter:


    /**
    * Implementation of hook_apachesolr_modify_query().
    */
    function apachesolr_filtermultisitesearch_apachesolr_modify_query(&$query, &$params, $caller) {
    if ($caller == "apachesolr_multisitesearch") {
    // Limit to specific site search via the site hash.
    $query->add_filter('hash', 'code_retrieved_from_drush_vget');
    }
    }

    Sample code to rename tab:


    /**
    * Implementation of hook_search()
    */
    function apachesolr_mymodule_search($op = 'search', $keys = NULL) {
    switch ($op) {
    case 'name':
    return t('Custom Results');
    }
    }

    /**
    * Implementation of hook_menu_alter
    **/
    function apachesolr_mymodule_menu_alter(&$menu) {
    $menu['search/apachesolr_multisitesearch/%menu_tail']['title arguments'][0] = 'apachesolr_mymodule';
    unset($menu['search/apachesolr_mymodule/%menu_tail']);
    }

    I hope this helps someone else who needs this information in the future.

blogs: 

Add new comment

Plain Text

  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.

Plain text 2

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.