Skip to content

Instantly share code, notes, and snippets.

@juampynr
Created January 29, 2014 14:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save juampynr/8688805 to your computer and use it in GitHub Desktop.
Save juampynr/8688805 to your computer and use it in GitHub Desktop.
Drupal: Setting up Apache Solr locally when using aquia_solr module

Drupal: Setting up Apache Solr locally when using aquia_solr module

Acquia Search is a module within https://drupal.org/project/acquia_connector used on sites hosted at the Aquia Cloud.

By default, all environments except production will perform searches on Aquia's Solr instance in Read Only mode.

Setting up a local Solr Server

There are a few gotchas in setting a Solr Server locally when using aquia_search. Here is a step by step guide:

  1. Download and start Solr locally.
  2. Set $conf['apachesolr_read_only'] to 0 at settings.php. Otherwise content won't be indexed. Note remember to unset this once you are done or you may possibly alter production's Solr index.
  3. Go to admin/config/search/apachesolr/settings and clone Acquia Search environment.
  4. Run the following query to change the class that local uses to run Solr queries:
update apachesolr_environment set service_class = 'DrupalApacheSolrService', url = 'http://localhost:8983/solr' where env_id = 'acquia_search_server_1_0';
  1. Go to admin/config/search/apachesolr/settings/acquia_search_server_1_0 and verify that Drupal can connect to your local solr instance.
  2. Go to admin/config/search/apachesolr/settings/acquia_search_server_1_0/index and mark the content types that you want to index.
  3. Run the following commands to start indexing:
# Note you can also run cron but that will take longer and index just a bunch of nodes.
drush solr-delete-index
drush -v solr-index
  1. Search for anything, you should start seeing log messages at the terminal where your Solr server is running.If you ever need to debug Solr locally, these steps should help you to get set up.

Debugging the Solr index

If you want to verify what is being sent to Apache Solr when indexing, set a breakpoint on apachesolr_cron(), start your debugger and perform a search on your local environment.

Debugging Solr queries

The acquia_search module uses a custom class to perform queries to Solr. Set a breakpoint at Acquia_Search_Service->_sendRawGet() and debug a search in order to see what is being sent and returned by Solr.

@sorinbb
Copy link

sorinbb commented Jan 3, 2018

You might want to check out the config overrides that you can place in your settings.php file if we talk about Drupal 8 and Search API Server override it gonna look like this:

   $config['search_api.server.acquia_search_server'] = [
    'backend_config' => [
      'connector' => 'standard',
      'connector_config' => [
      'host' => 'localhost',
      'path' => '/solr',
      'core' => 'd8',
      'port' => '8983',
      ]
    ],
  ];

Note: That in UI you will not gonna see these overiden changes due to a D8 bug, so you can see it via following drush command:
drush cget search_api.server.acquia_search_server --include-overridden

@tobyontour
Copy link

I could hug you for posting that. You've just solved a really irritating issue for me.

@juampynr
Copy link
Author

I am glad that it helped you, @tobyontour!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment