Install and Start Apache Solr in 5 minutes

Install and Start Apache Solr in 5 minutes

Search has become a default way for users to find products on websites. Despite main navigation and other site navigation tools, more and more customers are using on – site search to find what they want. Speaking about default Magento search I don’t have much to say, I can only give you advice to use some custom solution to get the most of it for your UX.

If you want to go one step further and make the best solution for your Magento search, use Apache Solr. Ok? Ok! So, what is Solr?

“SolrTM is the popular, blazing fast open source enterprise search platform from the Apache LuceneTM project. Its major features include powerful full-text search, hit highlighting, faceted search, near real-time indexing, dynamic clustering, database integration, rich document (e.g., Word, PDF) handling, and geospatial search. Solr is highly reliable, scalable and fault tolerant, providing distributed indexing, replication and load-balanced querying, automated failover and recovery, centralized configuration and more. Solr powers the search and navigation features of many of the world’s largest internet sites.”

http://lucene.apache.org

There’s a lot of terminology in this official Apache Solr definition,  but don’t let that scare you. Installing example Solr and start it is very easy and we are going to do that in this article. So let’s start!

I’ll assume you’re on a Linux or Mac environment. I’ll guide you trough tutorial, live on staging server. First of all, you need to download latest Solr version. You can get it here. Or you can execute wget command from command line interface:

wget http://ftp.carnet.hr/misc/apache/lucene/solr/4.5.1/solr-4.5.1.tgz

wget

When file is successfully downloaded it will be tar.gz format, so you will need to extract it. Easily you can do this with next command:

tar -zxvf solr-4.5.1.tgz

tar

After we finish downloading and extracting it, you must have the following in your directory:

solr_review

 The next step is to position your command line to solr-4.5.1./example. In that directory you have file called start.jar. Executing that file from command line you are starting Apache Solr. There are two ways to start Apache Solr:

Scenario 1: Start it and keep running until console is closed.
Scenario 2: Start and run in background until you choose to stop it from command line.

When you are dealing with live projects then you should choose “scenario 2“. For all other purposes like testing on local/staging server use “scenario 1“, because like other platforms, Solr use resources. I’ll show you Linux commands for both cases so let’s do it for first case:

The first thing you need is set your position to “example” directory, which you can find under: yoursrootdirectory/solr/solr-4.5.1./example

moving to example

Scenario 1

Now when you are in example directory, you can check for your start.jar file with ls command. That is our file which we need to execute for starting Solr. Solr will start with this command:

java -jar start.jar

start java

Now your Solr is started and ready for use. Default Solr port is 8983 which you can change in example/etc/jetty.xml. Look for the line  <Set name=”port”><SystemProperty name=”jetty.port” default=”8983″/></Set> and change it. For this article I set port to 8984 and when I visit my URL i see my Solr running:

Solr Started

This Solr will run until you close your command line interface or you press Ctrl + C.

 Scenario 2

For this scenario we just need a different starting command. Position yourself into example directory like I mentioned before and execute this command:

nohup java -jar start.jar &

Start Solr in background

Running this command lets you to run Solr in background and now you can close your command line or press Ctrl + C, and your Solr will continue running until we kill the process. How to do that? I will show you in the next steps: For listing all processes from one user execute this command:

ps -u user (user is your username which you used in connection ).

After that you will get a list of processes under your username:Background Process List

 Now you see my java process is under number 15433. I will use that number and execute command to kill process:

kill 15433

At the end of this article you are able to set up your Solr. I must make a note that this is a default Solr configuration. Magento Enterprise Edition ( EE ) versions 1.8.0.0 and later, enable you to configure Solr for catalog search. For Magento Community edition there are a lot of Solr extensions.

Hope you’ll find this useful and in further articles my plan is to show you how to set up Magento for Solr search. Happy Coding and don’t forget to leave us comments below or contact us in case you need someone to help you out with your Magento development.

Related Inchoo Services

You made it all the way down here so you must have enjoyed this post! You may also like:

How To Connect Google Analytics 4 To Magento 2 Bojan Mareljic
Bojan Mareljic, | 36

How To Connect Google Analytics 4 To Magento 2

Ground zero – planning phase Vesna Pozderac
Vesna Pozderac, | 0

Ground zero – planning phase

Easily manage LAMP name based virtual hosts Marko Martinovic
Marko Martinovic, | 4

Easily manage LAMP name based virtual hosts

15 comments

  1. Hi My self I am Raghunath, an e-commerce developer. We are using Solr search in our application. I am facing an issue with the products search sort by Low to High and Vice versa. The exact issue is in the first page after click on Ascending sort products displays exactly based on sort but when we click on the next page again the product price starts with less than the price ended in the first page. So we decided to do a Solr refresh. But i am not sure how to perform the Solr Refresh. Can anyone please suggest me?

  2. Magento officially supports up to Solr version 3.6.2. Your article hints that it is stable to use newer versions. Is it? Is there a limit to which version can/should be used on latest versions of M1 EE?

  3. Hi,
    I’m having some problems with starting the Apache Solr Search.

    After installing java 8 on my SLES 11 64 Bit Server, I unpacked solr 6.0.1 to /srv/apache-solr-6.0.1/

    After this i wanted to start the software, but when i tried:

    java -jar start.jar
    the subfolder: /srv/apache-solr-6.0.1/solr/example/

    I recieve the following error:

    Error: Unable to access jarfile start.jar

  4. Hi All,

    Could you please let me know we can upgrade solr from Solr-4 to Solr-5 on windows platform. Am trying to collect the details am not getting much of it.

    Regards,
    Adarsh

  5. @bobmc
    did u get ur problem solved?
    as i am having a similar problem
    in my solr package there is no start.jar file
    can nyone help?

  6. I have a new install of 4.7.2 and when i run

    java -jar start.jar 

    in my examples directory, I get a long stream of errors that terminates the program. I have not modified the program, but it looks like it tried to create collection1 for me. The first error I get is this:

    4626 [coreLoadExecutor-4-thread-1] ERROR org.apache.solr.core.CoreContainer – Unable to create core: collection1
    org.apache.solr.common.SolrException: Index locked for write for core collection1

    I see that the file exists: example/solr/collection1/conf/data/index/write.lock and that the directory for collection 1 was created the day I first ran it and tinkered with the extension in magento.

    I would like to know what started to happen as the first time I executed it, it seemed to work fine.

    Once I get past this, I would like to use the extension mentioned by Kannan and would like to know specifically where to put the solrconfig.xml and schema.xml files provided in that package, and how to make it work

  7. Hi guys!

    @PJ @Johnboy @Jay recently I was dealing with Solr and Magento CE version. I used Solr Bridge Search extension. It seems to be a good solution for Magento CE and it has good documentation.

    I didn’t try any of free extension but for my next article the plan is to connect Solr with CE. I hope to find some sort of good and free solution.

    Cheers.

  8. Much like PJ I have always been curious as to trying out SOLR on CE, but no idea which of the extensions out there are any good?

  9. Thank you,
    that’s much but it’s same in zip I download tutorial (works for me). How I integrate with CE please help. Is there other free extension found one but not works for me.
    Thanks

  10. Which extension are you using for the Community Edition? There are so many, which one is the best and for what purposes?

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <blockquote cite=""> <code> <del datetime=""> <em> <s> <strike> <strong>. You may use following syntax for source code: <pre><code>$current = "Inchoo";</code></pre>.

Tell us about your project

Drop us a line. We'd love to know more about your project.