If you need to change your Solr schema, you can test it locally. Acquia Support requires any schema changes to be tested on your own servers before accepting them for production on Acquia Cloud. Be sure to read our documentation on custom Solr configuration. You may also find the drupal.org documentation on Customizing the Solr configuration useful.
Rather than modify Solr's schema.xml
, Acquia recommends adding items into the following files, which you can add to the same directory as your regular Solr schema files:
schema_extra_fields.xml
solrconfig_extra.xml
These files are included when your schema.xml
loads. Using them prevents you from modifying your approved schema.xml
and solrconfig.xml
files. Because Acquia Support must approve any changes to the schema files, using the extra*
files can significantly improve your ability to get a custom configuration approved.
To test a file (such as schema.xml
) locally, you must prepare your environment and then configure its Drupal settings.
Prepare your environment
Allow this process to run during your testing. Note that every time you want to test a change to a configuration file, you will need to stop the service (using CTRL-C) and then restart it.
- Optional step: if you don't have a Drupal site running locally, you can install Acquia Dev Desktop on your local computer. For testing, you can choose to add some content to a newly-created site or clone an existing site.
- Make sure you have the required Solr search modules downloaded (not necessarily installed at this point) in your Drupal site.
- Download the Solr package from apache.org and uncompress the file into your user directory (for example,
/solr/[VERSION]
). You will use this shortly to run a Solr instance locally for your Drupal site to connect to. If you want to run multiple versions, you can have multiple folders. - Change to the directory in which you placed Solr and make a copy of the example folder. Name the folder for the project (such as,
~/solr/apache-solr-[VERSION]/myproject
). This gives you an instance of theschema.xml
or other files that you can configure, while also keeping default copies.
- Copy only the files for the matching Solr version from the Drupal module you are using to connect to Solr, into the new project's
solr
directory.The source directory depends on the module you are using. Here are some example locations:
- Apache Solr Search Integration module:
docroot/sites/all/modules/apachesolr/solr-conf/solr-[SOLR VERSION]/*
. - Search API Solr module:
docroot/sites/all/modules/search_api_solr/solr-conf/[SOLR VERSION]/*
.
The destination configuration directory depends on the Solr version:
- Solr 4.5.1:
~/solr/apache-solr-4.5.1/myproject/solr/collection1/conf
- Solr 3.5:
~/solr/apache-solr-3.5.0/myproject/solr/conf
You should copy the source files to the destination directory above. This folder is where you will be making any needed changes that you need to test.
- Apache Solr Search Integration module:
- Optional step: By default, it takes two minutes for the queued content to process. Make this shorter for local testing by editing the local
solrconfig.xml
and changing the value to2000
(two seconds).
- Open a command prompt window, and change to the
~/solr/apache-solr-[VERSION]/myproject
directory, and start the local Solr instance with the following command:java -jar start.jar
Configure your Drupal settings
Next you should configure your local Drupal site to connect to the local Solr instance. The steps vary depending on the module you are using; please consult each module's documentation.
You should use the following Solr endpoint URL during your configuration: http://localhost:8983/solr
Now... test!
After connection, you can now test indexing and searching using this connection. You can also use the Solr analysis tool at [Solr URL]/admin/analysis.jsp, which you only have access to locally and not on Acquia's instance.
Remember that every time you want to test a change to a Solr configuration file, you will need to stop the service that you left running in your command line (using CTRL-C) and then restart it after the changes are done.
Additionally, we recommend using Solr Devel module to debug Solr indexing and queries from within Drupal.