Contents
- Overview
- Assumptions for using Solr in a development environment
- Prerequisites
- Configure Solr and Magento
- Prepare Solr for production
Overview
Magento Enterprise Edition (EE) version 2.x enables you to configure either of the following as a catalog search engine:
- Full text search using the MySQL database (the default)
-
The Apache Solr search engine Solr enables you to provide your web store users with a powerful full-text search engine that includes:
- Faceted search
- Dynamic clustering using SolrCloud
- Database integration
See one of the following sections for more information:
- Intended audience and purpose of this topic
- Comparing the search options
- More information about the Solr solution
Intended audience and purpose of this topic
This topic is intended for Magento EE administrators and systems integrators who have some familiarity with search engines鈥攊deally, who also have Solr configuration experience. No programming is required to perform the tasks discussed in this topic.
This topic discusses a simple Solr configuration that uses the example Solr configuration provided with Solr, default Solr integration options provided with Magento EE, and also explains how to configure Magento EE to use Solr. Advanced configuration tasks鈥攕uch as setting up dictionaries鈥攁re beyond the scope of this topic.
The example Solr configuration is not intended to be used in a production site. It's for testing and development only. Because it's simple to use, it's a great way for you to learn more about Solr.
Comparing the search options
The following table provides a quick comparison between Magento with the default MySQL full text search and Magento with Solr search.
Feature | Magento with MySQL full-text search | Magento with Solr search |
---|---|---|
Full text search | Yes and also supports two additional search modes:
|
Yes† |
Search recommendations | Yes | Yes |
Faceted search (used in layered navigation) | Yes | Yes |
Range (such as price range) | Yes | Yes |
Sort-by options (for example, sort by relevance) | Yes | Yes |
Zero results tips or results correction | No | Yes |
Suggestions | No | Yes |
Clustering | No | Yes |
Attribute weight based on attribute settings | Yes | Yes |
Search localized characters | No | Yes |
Word delimiter (for example, searching for spider man or spiderman return spider-man ) |
No | Yes |
鈥犫斺淟ike鈥 searching is supported by MySQL full text search but not by Solr.
More information about the Solr solution
Solr runs as a standalone full-text search server in a servlet container such as Jetty (which is used by the Solr example configuration) and Tomcat.
Solr uses the Lucene Java search library for full-text indexing and search. Your applications interact with Solr using HTTP POST (in JSON, XML, CSV, or binary formats) to index documents and using HTTP GET to retrieve search results back as JSON, XML, or a variety of other formats (Python, Ruby, PHP, CSV, binary, and so on). If you鈥檙e a programmer, try the Solr tutorial. Whether you鈥檙e a programmer or not, read the Solr FAQ.
No programming is required to implement Solr as discussed in this topic.
Solr鈥檚 powerful external configuration allows it to be tailored to almost any type of application without Java coding, and it has an extensive plug-in architecture when more advanced customization is required. Solr is highly scalable, providing distributed search and index replication.
Customize the Solr search engine at your own risk. Magento supports only the options displayed in the Admin. Customizing the Solr engine itself, while potentially useful, can cause issues with Magento. If you encounter problems with your customizations, do not contact Magento Support; instead, consult the resources available from the Apache Solr Wiki.
In this topic, you鈥檒l use the example configuration provided with Solr and Magento鈥檚 provided Solr configuration to implement a simple, quick integration with Solr.
Some reasons to use Solr with Magento include:
- Magento ships with a sample Solr configuration that enables you to provide users with a powerful search engine without your needing to customize any code.
- You get better performance of search, catalog views, and layered navigation.
- When the system is under load, Solr avoids frequent updates of the MySQL
catalogsearch_fulltext
table and alleviates issues with database table locks.
Assumptions for using Solr in a development environment
This topic discusses a simple way to set up Solr in a development environment. No coding is required.
The following suggestions in this topic should not be used in a production environment because they鈥檙e potentially unsafe:
- Starting the example Solr web application using
java -jar start.jar
because it鈥檚 not maintainable. You should script starting and stopping Solr instead. - Using the example Solr web application is not recommended because you should customize a new web application for your use. You can also compare application servers to determine if the bundled Jetty application server is appropriate for your needs.
- Turning off your UNIX firewall is not recommended in production. (As an alternative, you can set up firewall rules to allow Magento and Solr to communicate.)
-
Setting SELinux to
permissive
SELinux settings are entirely up to you. Magento does not recommend particular settings; however, be aware that setting up SELinux is very complex.
Prerequisites
The tasks discussed in this topic require the following:
- Disable the UNIX firewall and SELinux
- Latest available Java version
- Latest available version of Solr 4
Firewall and SELinux
By default, UNIX systems generally enable a firewall with restrictive rules and also enable SELinux, which imposes other types of security on the operating system. It鈥檚 easier to run Solr in development by disabling the firewall and SELinux but that choice is up to you.
If you choose to enable your firewall and SELinux, you must set up rules to allow TCP traffic between Magento and Solr on Solr鈥檚 listen port (8983 by default).
Disable iptables and SELinux
To stop the iptables
(firewall) service, enter the following command as a user with root
privileges:
service iptables stop
To set SELinux for permissive mode:
-
To determine if SELinux is enabled, enter the following command:
getenforce
Enforcing
displays to confirm that SELinux is running. (IfPermissive
displays, continue with the next section.) -
To change to permissive mode, enter:
setenforce 0
Set up rules for iptables and SELinux
To set up rules to allow communication with the firewall or SELinux enabled, consult the following resources:
- iptables how-to
- How to edit iptables rules (fedora project)
- 25 Most Frequently Used Linux IPTables Rules Examples
- Introduction to SELinux (CentOS.org)
- SELinux How-To Wiki (CentOS.org)
Install the Java Software Development Kit (JDK)
To determine if Java is already installed, enter the following command:
java -version
If the message java: command not found
displays, you must install the Java SDK as discussed in the next section.
This topic discusses using Jetty, which comes with Solr. Consult another resource, such as the Solr Wiki, to use Tomcat with Solr.
To see if you鈥檙e currently running Jetty and to check the version, see How to find out the version of Jetty.
See one of the following sections:
Install the JDK on CentOS
See this article on digitalocean.
Be sure to install the JDK and not the JRE.
Install the Java 6 or later SDK on Ubuntu
To install the Java 6 SDK, enter the following command as a user with root
privileges:
apt-get install openjdk-6-jdk
To install Java 7, enter the following command as a user with root
privileges:
apt-get install openjdk-7-jdk
Java version 7 might not be available for all operating systems. For example, you can search the list of available packages for Ubuntu here.
To install JDK 1.8 on Ubuntu, see Oracle documentation.
Install Solr 4 and Jetty
The Apache Solr package installs both Solr and Jetty. If Jetty is already installed, see the Solr with Jetty Wiki for more information.
Tomcat is also a supported servlet container for Solr but discussing how to set up Tomcat with Solr is beyond the scope of this topic. For more information, see the Solr With Tomcat Wiki.
To install Solr and Jetty:
-
As a user with
root
privileges, usewget
or a similar command to download the latest version of Solr 4 to an empty directory such as/opt/solr
.An example follows.
mkdir -p <empty-directory<> cd <directory> wget http://www.trieuvan.com/apache/lucene/solr/4.10.4/solr-4.10.4.tgz
Messages similar to the following display to confirm a successful download.
wget http://www.trieuvan.com/apache/lucene/solr/4.10.4/solr-4.10.4.tgz --2015-07-11 14:39:05-- http://www.trieuvan.com/apache/lucene/solr/4.10.4/solr-4.10.4.tgz Resolving www.trieuvan.com... 66.201.46.168 Connecting to www.trieuvan.com|66.201.46.168|:80... connected. HTTP request sent, awaiting response... 200 OK Length: 35866329 (34M) [application/x-gzip] Saving to: 鈥渟olr-4.10.4.tgz鈥 100%[==============================================================================================>] 35,866,329 8.63M/s in 4.3s 2015-07-11 14:39:09 (8.04 MB/s) - "solr-4.10.4.tgz" saved [35866329/35866329]0
-
Unpack the Solr installation; an example follows.
tar -xvf solr-4.10.4.tgz
Find us on