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).
Installing Solr
Note: You need to install java in your system.
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:
Once the zip has been uncompressed in your home directory, copy the files inside the folder file in a new folder called «solr» in /opt:
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’?
Reindex And Start Using Your New Solr Search Engine
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:
httpvh://www.youtube.com/watch?v=blWSP9BwyBM
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.
6 Comments
anjej · December 16, 2012 at 7:14 pm
But solr included only enterprise edition. Use Sphinx
Tim · December 19, 2012 at 4:05 am
Greetings, I am looking to create custom ranges for solr and Magento however I don’t know the field mapping between solr fields and magento db. I am guess that it has more to do with product input type for the attribute rather the attribute name?? I have done some testing to see this and any attribute with the product input type of price will have the range set. If possible could you verify this?
Thanks,
Tim
Pau · December 19, 2012 at 6:17 am
Hi Tim,
I’m not clear with the question you’re asking. Could you please put a practical example so that I can help you?
Thanks!
Timothy Turner · December 27, 2012 at 9:32 pm
I would like to have a facet be a range (like the price field). I have tinkering with solrconfig.xml and the solr schema.xml however, I unable to alter the data coming into solr from magento?
I have a dynamic attribute in the “attr_nav_select_my-attrubute” that I have set to index. And I would like to display this attribute as a range facet. I can alter some settings with using the invariant section of the solrconfig.xml however I don’t know where to go to explicitly change a facet attribute to a range facet attribute. The best I could do was change the already defined range attribute values.
So, my question: where and how do I change an attribute to be a range facet?
Tim
Naresh · January 29, 2014 at 6:55 am
I have the small problem in this “[magento-installation]/lib/Apache/Solr/” in this location i don’t have the folder like “conf”. and i downloaded it from “http://apache.mirrors.lucidnetworks.net/lucene/solr/4.6.1/”
Any thing wrong i did here ?
Thanks.
Pau · January 29, 2014 at 9:12 am
Hi Naresh. This guide was done for Solr 3.5. Solr 4.6 works in a different way and I’m not sure it will work by default. I’ll check and update the ticket