Magento 2 Solr Integration

Magento 2 Solr Integration

Rate this article

Share this article

Read this blog on Magento 2 Solr integration for more information.

Do you know how many customers your Magento store is losing just because your visitors can’t find the products they need since the search system is imperfect? Huge stores with an extensive amount of products suffer from it dramatically.

When a customer doesn’t know the exact product name, a search for the good he wants turns into a long adventure. Grouping by categories and Improved Sorting might make the situation a little bit better, but if one doesn’t know what category a product belongs to or how its name is spelled, the search result might be inappropriate.

To solve this problem Magento offers a full-text search. Starting from version 1.8.0.0 Magento Enterprise supports not only the full-text search based on MySQL (used by default) but also the Apache Solr search engine.

magento 2 solr integration

Taking a fork from Solr and starting a search project from scratch can be difficult and will involve heavy developer costs. When on a CMS like Magento, it is not advisable to take this approach. Instead, it is better to use a Solr-based search extension like the one mentioned below.

How to do Magento 2 Solr Integration Easily

Magento 2 search is based on Elasticsearch. And there is no ready-made plugin to install native Solr easily. However, that does not mean that you cannot use a Solr-based search plugin for your Magento store! This gives you an added advantage of not having to set up Solr from scratch and you can modify the settings any time easily from the GUI that comes with the plugin.

Magento 2 Solr Plugin

On Magento 2,  all that you need to do is install the ExpertRec site search extension from the marketplace. This will automatically replace your default search and add a search that has facets inbuilt. You can do further customization in the Expertrec Dashboard that comes along with the plugin.

Magento 2 Solr Pricing

Magento 2 Solr Integration

Magento 2 Solr reindex

If you have used the plugin mentioned above, then this is also very straightforward. The ExpertRec site search extension allows you to reindex your catalog at the press of a button.

FAQs

How to Install and Set Up Magento 2 With Solr?

Disclaimer: If Solr is configured improperly, it may have a serious effect on server security. Set up your firewall carefully to defend Solr from potential malicious actions.

The directions for Magento Solr setup given below are for Debian or Ubuntu installations; commands may differ for other installations.

  • Install Java.

# aptitude install openjdk-7-jre-headless

  • Set up Solr installation directories

# mkdir /srv/solr

# useradd -d /srv/solr -s /bin/bash solr

# chown solr:solr /srv/solr/

# su – solr

  • Download the Solr 3.4 installation package

$ wget http://archive.apache.org/dist/lucene/solr/3.4.0/apache-solr-3.4.0.tgz

$ tar xf apache-solr-3.4.0.tgz

  • Copy Magento configurations for Solr.

$ cp -r /path/to/magento/install/lib/Apache/Solr/conf/* apache-solr-3.4.0/example/solr/conf/

  • Create an auto-start code (add the contents to /etc/init.d/apache-solr)

#! /bin/sh

### BEGIN INIT INFO

# Provides:          apache-solr

# Required-Start:    $all

# Required-Stop:     $all

# Default-Start:     2 3 4 5

# Default-Stop:      0 1 6

# Short-Description: Apache Solr

# Description:       Apache Solr search engine

### END INIT INFO

# Author: XXXXX XXXXXXXX <XXXXXXXXX@amasty.com>

SOLR_DIR=”/srv/solr/apache-solr-3.4.0/example”

SOLR_USER=”solr”

JAVA_OPTIONS=”-Xmx1024m -DSTOP.PORT=10000 -DSTOP.KEY=jetty-stop-key -jar start.jar”

LOG_FILE=”/var/log/apache-solr.log”

JAVA=”java”

case $1 in

        start)  

                echo “Starting Solr”

                su – $SOLR_USER -c “cd $SOLR_DIR && exec $JAVA $JAVA_OPTIONS >$LOG_FILE 2>&1 &”

                ;;

        stop)   

                echo “Stopping Solr”

                su – $SOLR_USER -c “cd $SOLR_DIR && $JAVA $JAVA_OPTIONS –stop”

                ;;

        restart)

                $0 stop

                sleep 1

                $0 start

                ;;

        *)      

                echo “Usage: $0 {start|stop|restart}” >&2

                exit 1

                ;;

esac

:

  • Make it executable 

# chmod 755 /etc/init.d/apache-solr

  • Create logrotate configuration (add the contents to the file /etc/logrotate.d/apache-solr).

/var/log/apache-solr.log {

        daily

        rotate 7

        compress

        delaycompress

        missingok

        notifempty

        create 640 solr adm

}

  • Set up the file logs

# touch /var/log/apache-solr.log

# chown solr:adm /var/log/apache-solr.log

# chmod 0640 /var/log/apache-solr.log

  • Launch Solr and add it to auto-start.

# update-rc.d apache-solr defaults

# service apache-solr start

Settings of Magento Enterprise to setup with Solr:

  • Go to Magento admin panel System / Configuration;
  • In the group CATALOG choose Catalog / Catalog Search;
  • Then choose Solr in the field Search Engine;
  • Enter your-site-ip in the Solr Server Hostname field;
  • Enter 8983 in the Solr Server Port field;
  • Enter solr in the Solr Server Path;
  • Press the Test connection button. If it has changed its color to green, Solr is connected and is ready for use;
  • Save the changes (press the Save Config button).

What are the Differences Between Elasticsearch and Solr?

The main difference between them is that Elasticsearch is run by its employees, whereas Solr is an open-source search engine.

How is Magento Solr Used?

Magento Solr is used to craft different search tactics and for its great library. Configure Solr to work with a pre-configured, Magento-ready plan. Create basic tests, performance metrics, and relevant changes.

What are the Benefits of Magento SOLR Integration?

There are many benefits to using the integration of Magento Solr to optimize the search engine. One of the main reasons is that Solr is an open-source search engine; therefore, it allows you to make changes to the software. Their integration delivers relevant search results and full-text highlight search. It also gives a spell-check guide with the “Did you mean?” feature and has rich document-handling capabilities, suggestions, and, clustering.

Are you showing the right products, to the right shoppers, at the right time? Contact us to know more.
You may also like