Mastering solr part I: Development environment
At the moment the best search engine available for Drupal is Apache Solr. There are many Drupal sites which actually use Solr to power their search. Using the configuration options of the solr integration modules, the search is already quite decent, and this is where many developers stop tweaking Solr. In some situations however, it might be necessary to tweak solr beyond the standard configuration options. Luckily this tweaking is relatively easy: almost all tweaking of Solr can be done by adding and/or altering parameters to the request to Solr. The Solr integration modules on the other hand, offer hooks to alter the parameters send to Solr. So if the search behavior should be tweaked, the question is not 'Can it be done?', but rather 'What should I send to Solr, to get this behavior?'. This blog series will explain how Solr works in the first place, and will show how to debug and optimize indexing and querying.
Setting up your development environment
In order to experiment with Solr, you need to run Solr locally and have one of the Solr integration modules. There are currently two Drupal modules which can interact with Solr:
- Apache Solr Search Integration (http://drupal.org/project/apachesolr)
- Search API (http://drupal.org/project/search_api) together with Search API Solr search (http://drupal.org/project/search_api_solr)
I will not eloborate on which module is best in this blog post series. For the rest of this series, I will use the Search API module in the examples, but you can also use the Apache Solr Search Integration module.
To set up your environment for Apache Solr Search Integration, follow the tutorial on the following url: http://nickveenhof.be/blog/simple-guide-install-apache-solr-3x-drupal-7.
To set up your environment for Search API, follow the following tutorial: http://zugec.com/73-how-setup-search-api-apache-solr
Both tutorials are a littlebit old, so be sure to take Solr version 3.5 or 3.6 instead of 1.4.1.
At the end of each tutorial, you should have a working Drupal test site with an installed Solr module. Solr should be running in a so called jetty container, which is the case if you used 'java -jar start.jar'. You should have a terminal running, in which you can see the log:
You also should be able to see the solr admin page on http://localhost:8983/solr/admin/:
Now we have our development environment, we can start tweaking Solr. But first we need some content. For the moment you can make some basic pages. Be sure to create at least one page with the title 'fox' containing the text 'Foxes are fascinating animals'. We use this page as an example in tweaking the Solr settings. Proceed to part II: Mastering solr part II: A solr request en the schema.xml