Have you ever worked with the Apache Solr Search Integration project? I certainly hope so! At Acquia, we have invested a lot of time to make this module stable for Drupal 7. We did not make any sacrifices in regards of speed and/or optimizations. For one, I have spent a lot of time during my thesis in making the Apache Solr Search Integration module awesome and I also tried to understand (and eventually understood!) why Peter Wolanin was so reluctant in accepting to rely on some of the upcoming and popular modules.

You will see that this module is still a stand-alone module and we have good reasons for that. Let’s assume that you have a huge website with tons of nodes and are moving away from contrib modules, the last thing you want to see is that your contrib module depends on many other modules and eventually depend on thebugfixing speed of that contrib module. Also, we needed to have an easy backport path to Drupal 6 and this is also one of the reasons why the Apache Solr Search Integration module does not depend on Entity Api and Ctools. For the critics : it does have ctools integration whenever ctools is enabled.

The Drupal 6.x-3.x branch of Apachesolr has the exact same API and schema as the 7.x-1.x branch. This has the additional benefit that it allows you to create the following schema.

Solr Multisite

So, if you pay close attention, you can see that many sites talk to the same index. They can use the same index and search each others content. If you want to enhance this experience, it is recommended you install the apachesolr_multisitesearch module that allows you to see which sites have their content indexed in the shared Solr index. It also allows you to isolate a site and only let that site search its own content.

Solr Multisite compare

Coding for multisite

The following code snippet should explain how the linkage happens between two Drupal sites. This snippet is by no means something you should copy paste for use in your production site. It explanatory :-)

function custom_module_apachesolr_query_alter(DrupalSolrQueryInterface $query) {
  // Add our hash to the filter, this limits the search set to the current site only
  $query->addFilter('hash', apachesolr_site_hash());
  // Only search within the story content type, since a multisite environment cannot
  // share ids we need to filter on the machine name. You can link content types across sites
  // if they share the same machinename
  $query->addFilter('bundle_name', 'story');  
}