Install and configure Solr
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
This topic is intended for Magento EE administrators and systems integrators who have some familiarity with search engines—ideally, 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—such as setting up dictionaries—are 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.
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’re a programmer, try the Solr tutorial. Whether you’re a programmer or not, read the Solr FAQ.
No programming is required to implement Solr as discussed in this topic.
Solr’s 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’ll use the example configuration provided with Solr and Magento’s 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_fulltexttable 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’re potentially unsafe:
- Starting the example Solr web application using
java -jar start.jarbecause it’s 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
SELinux settings are entirely up to you. Magento does not recommend particular settings; however, be aware that setting up SELinux is very complex.
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’s 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’s listen port (8983 by default).
Disable iptables and SELinux
To stop the
iptables (firewall) service, enter the following command as a user with
service iptables stop
To set SELinux for permissive mode:
To determine if SELinux is enabled, enter the following command:
Enforcingdisplays to confirm that SELinux is running. (If
Permissivedisplays, continue with the next section.)
To change to permissive mode, enter:
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:
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’re 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
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
apt-get install openjdk-6-jdk
To install Java 7, enter the following command as a user with
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
wgetor a similar command to download the latest version of Solr 4 to an empty directory such as
An example follows.
mkdir -p <empty-directory<> cd <directory> wget http://archive.apache.org/dist/lucene/solr/4.10.4/solr-4.10.4.tgz
Messages similar to the following display to confirm a successful download.
wget http://archive.apache.org/dist/lucene/solr/4.10.4/solr-4.10.4.tgz --2016-10-01 15:54:37-- http://archive.apache.org/dist/lucene/solr/4.10.4/solr-4.10.4.tgz Resolving archive.apache.org... 22.214.171.124 Connecting to archive.apache.org|126.96.36.199|:80... connected. HTTP request sent, awaiting response... 200 OK Length: 150059757 (143M) [application/x-gzip] Saving to: "solr-4.10.4.tgz" 100%[==========================================================>] 150,059,757 8.99M/s in 4.5s 2016-10-01 15:55:23 (3.18 MB/s) - "solr-4.10.4.tgz" saved [150059757/150059757]
Unpack the Solr installation; an example follows.
tar -xvf solr-4.10.4.tgz