Apache Solr is a system for indexing and searching site content. Pantheon provides Apache Solr as a service that works well for the majority of sites on the platform. No permission or action is required from Pantheon to use Solr.
Currently, the version of Solr on Pantheon is Apache Solr v3.6.
However, If you are looking for additional features for more advanced use cases, you may want to consider an external Solr service.
The Opensolr service offers a number of features including:
- Smart full-text search
- Similarity search
- PDF and document search with opensolr Tika
- JTS Polygonal geo-spatial search
- REST-like API
This doc covers Opensolr configuration for Drupal sites. For WordPress-Opensolr integration, see Opensolr's WPSolr Integration tutorial.
Before You Begin
This doc assumes that you have already enabled:
- Drupal 7 the ApacheSolr module
- Drupal 8 the Search API Solr module using Composer (required by Search API Solr to manage dependencies).
Create a New Index
After you have signed up at Opensolr.com, log in and click My Indexes, then click Add New.
Set Up the Index
To create your index:
- From the Version list on the left, select the environment's SOLR version
- Select your preferred region
- Choose a name for your index
After filling out the appropriate fields, click Add Index to create your index. You will then see a card on your dashboard for your index. Click on the index name to go to the overview page for your index. From this page, copy the following information before moving forward:
- Connection URL
Set up Index Security
If you are using Drupal 8 and the Search API module, you need to setup (or disable) HTTP authentication for your Opensolr servers. The ApacheSolr module for Drupal 7 does not support HTTP auth. To do this:
Click the Security link in the left column of the Opensolr dashboard.
To configure, enter a username and password, then click Save. Write it down, as you will need to enter this username and password on the Drupal Search API Add Server form.
Opensolr will remove any special characters, including dashes (
-) from the username and password.
To remove HTTP Authentication, Click Remove HTTP Auth
Configure Solr Module
Configure Drupal’s ApacheSolr Module
To get your index working with a Drupal site, set some configuration options in the ApacheSolr module. You can quickly reach the ApacheSolr settings page by appending the following to your site’s URL:
Provide two items to the ApacheSolr configuration:
- ServerURL: Paste the Connection URL from Opensolr here.
- Description: Briefly describe your index here.
When you've finished, click Save.
A schema must be pushed in each environment (Dev/Test/Live).
Test Your New Solr Connection
Now that you created the index and configured the ApacheSolr Drupal module to point to the new index, test the connection and make sure ApacheSolr can communicate with the Opensolr index.
admin/config/search/apachesolr/settings and click on your index.
To test the connection, click Test Connection.
If Drupal returns a success message like “Your site has contacted the Apache Solr server”, you have successfully set up your index. If not, go back and complete the configuration steps above.
Configure Drupal’s Search API Module
To get your index working with a Drupal 8 site, set some configuration options in the Search API module. You can quickly reach the Search API settings page by appending the following to your site’s URL:
Provide these items to the Search API Search configuration:
- Server Name: Enter the name for the server; including the name Opensolr is a helpful hint here.
- Under Backend, choose "Solr".
- Solr Connector: If you enabled HTTP Auth in Opensolr, choose Basic Auth. If you disabled it, choose Standard.
- HTTP protocol: HTTPS
- Solr host: Hostname from your Opensolr connection info page.
- Solr port: Port copied from your Opensolr connection info page.
- Solr path:
/solr. Depending on the server provider, this may need to remain blank. See Opensolr's Connection Issues FAQ for more information.
- Solr core: The name you gave your Solr core on the Opensolr connection info page.
If you chose Basic Auth, you will see a section for HTTP Basic Authentication. Enter the username and password values from your Opensolr Index Security page.
Leave everything else with default values provided and click Save. On the resulting Search API server configuration page, you should see messages indicating the Server and Core connections were successful:
Add Search API Solr Configuration Files to Opensolr
Your Opensolr server now needs the Search API Solr
schema.xml and other configuration files. These are located in your site code under
module/contrib/search_api_solr/solr_conf, in a sub-directory according to the Solr version you are using on Opensolr.
Create a zip archive of the files in your Solr version's directory. To do this from the CLI:
# From the solr version directory zip ~/solrconfig.zip ./*
The resulting zip file will be in your home folder.
Go to the Opensolr instance, and click on the "Configuration" tab.
Upload the zip archive.
Add Search Index and Fields
Now that you've created the server connection, add an index by visiting
admin/config/search/search-api and clicking on the Add index button. Provide the information about your index:
- Index name: The displayed name you wish to give the index.
- Datasources: In this section, check the boxes corresponding to the entities you want indexed and available for searching. Configure each Datasource selected to indicate which items should be included in the index.
- Server: Select the Opensolr server you just configured.
When you have finished, click Save.
Next, add the fields your index should include for indexing.
- Click on the Fields tab for your search index, then click the Add fields button.
- Select the fields to include in your index.
- When you have finished, be sure to click Save changes.
Customize Your Configuration
If you'd like to create custom configurations or manually edit your index, synonyms list, stopwords, etc., you can do so by clicking on the Configuration icon on your Opensolr Search Index's Tools page, then selecting the configuration file you wish to edit.