We recently upgraded a Magento Community Edition 1.4 to a Magento Enterprise Edition 1.11. Once the upgraded was done and everything was working fine, our client started complaining about the fact that the search results where not good in comparison to the previous version they had (with Magento CE 1.4).
After doing some research we found no specific reason for this: we changed the order criteria: tested it using relevance or name, but the results were not good. At this point we decided to use Solr.
Solr is the popular, blazing fast open source enterprise search platform from the Apache Lucene project. Its major features include powerful full-text search, hit highlighting, faceted search, dynamic clustering, database integration, rich document (e.g., Word, PDF) handling, and geospatial search. Solr is highly scalable, providing distributed search and index replication, and it powers the search and navigation features of many of the world’s largest internet sites.
Please note that Solr/Magento integration in Magento EE is already out-of-the-box. But with Magento CE you will need to install a module (I haven’t tested it).
If you want to use Solr with your Magento Enterprise, first of all you have to download the last version from the Official Website:
Download and uncompress the file in your home directory. Note that you’ll find a lot of files inside this zip file. The Solr files needed for using the engine are inside the «Example» folder along with other example files that can be deleted:
mkdir /opt/solr cp -R ~/apache-solr-3.6.1/example/* /opt/solr
Now copy all the files that are in your_magento/lib/Apache/Solr/conf/ to /opt/solr/solr/conf. I used something like this:
cp * /path_to_magento/lib/Apache/Solr/conf/* /opt/solr/solr/conf/
And paste them in /opt/solr/solr/conf. This is the default configuration that Magento provides for the Solr server. In order to check that Solr works fine in the system, start the solr server:
java -jar /opt/solr/start.jar
This will start the server (a lot of information will appear and the last lines should be something like this):
Solr is started. As you can see, by default the Solr port is 8983. You can finally check that everything is OK going to your magento url and using that port. In my case: http://magentosolr.lxc:8983/solr. You will get something like this:
Now we need to set up Magento in order to use the Solr server instead of the default Magento search. In the backoffice, go to:
System » Configuration » Catalog » Catalog Search
On the Catalog Search tab, select the Solr search engine. Click on the ‘Test connection’ button in order to check that the connection is OK. You should get a ‘Successful, test again’?
Everything is set up. There is only one missing point: reindexing. This is completely necessary so that Solr can index all the information about products and other data. This is also a final test. When reindexing, the terminal where we started Solr should start ‘moving’. The same will happen when performing a search from now on.
I’ve recorded a video so that you can see what will happen when reindexing and searching:
Conclusion And Further Steps
It’s actually very easy to install Solr and use it along with Magento. By default Solr works pretty fine. However, Solr can work much better by tweaking many different configuration files. We will work on that in following posts.