Installing and Configuring Apache Solr

In this article, I will explain how to install and configuring Apache Solr into your machine (either Linux or Windows). Currently, many organizations are using the Apache Solr as a search technology. The Apache Solr makes it easy for programmers to develop sophisticated, high-performance search applications with advanced features.

In the series of articles for the Spring Data Solr, this article also gives you exposure about the basic Solr architecture and features. In this article, we will be getting Solr up and running and also creating Solr collections with ingesting a variety of data sources into Solr collections.

Let’s install the Apache Solr into your machine.

System Requirements

There are following system requirements for installing the Apache Solr into your machine.

  • Apache Solr runs on Java 8 or greater.
  • CPU, disk and memory requirements are based on the many choices made in implementing Solr.

As you have seen that it is very few system requirement for the Apache Solr in the above section. Let’s download the Apache Solr latest version according to your machine.

Download Latest Release Version

Let’s download latest release of the Apache Solr from here. In this tutorial, I have downloaded and designed for Apache Solr 7.3. There are multiple archives available, you can download according to your machine.

Note: prior to the Solr 4.1 release, all distribution and artifact filenames contained an apache- prefix.

Installing and Configuring Apache Solr 7.3

Let’s unpack downloaded archive of the Apache Solr 7.3.

~$ unzip -q solr-7.3.1.zip

You can see about Solr’s directory layout into your machine as following diagram:

Configuring Apache Solr

Solr has been installed into your machine by only changing your working directory to the sub directory where Solr was installed.

~$ cd solr-7.3.1/

After installing and configuring, let’s launch Solr in your machine.

Launch Solr

To launch Solr, run: bin/solr start on Unix or MacOS; and bin\solr.cmd start on Windows. As following screenshot:

launch solr

Launch Solr in SolrCloud Mode

You can also launch two-node cluster of the Solr (both nodes on the same machine). Let’s use the following commands to launch Solr in SolrCloud Mode,

On Unix or MacOS

Use the following command to launch the Solr in SolrCloud mode in your Linux or MacOS machine.

bin/solr start -e cloud

On Windows

Use the following command to launch the Solr in SolrCloud mode in your Windows machine.

bin\solr.cmd start -e cloud

The above commands will run the Solr into interactive mode and asking to decide port number, collection name etc. You can provide this information at the run time. You can see that Solr is running by launching the Solr Admin UI in your web browser: http://localhost:8983/solr/ as following:

running solr

Let’s create collections in the Solr.

Creating Collections

You can use the following command to create collections in the Solr server.

bin\solr create -c Book

Let’s see the following diagram:

creating collection

Similarly you can create some more collections such as Order, Product and verify them on the Solr Core Admin as following diagram:

solr collections

After creating collections, let’s move to index these collections with Data.

Index the Solr Collections with Data

Solr includes the bin/post tool in order to facilitate indexing various types of documents easily. We’ll use this tool for the indexing examples below.

On Linux or MacOS

The data we will index is in the example/exampledocs directory. The documents are in a mix of document formats (JSON, CSV, etc.), and fortunately we can index them all at once:

solr-7.3.1:$ bin/post -c Book example/exampledocs/*

On Windows

Currently the bin/post tool does not have a comparable Windows script, but the underlying Java program invoked is available. You can see the D:\personal data\spring-data\solr-7.3.1\example\exampledocs directory contains post.jar, you can use it to post index to Solr server as following:

post-index

After indexing Solr Collections, let’s move to next section to basic searching functionality.

Basic Searching

Solr can be queried via REST clients, curl, wget, Chrome POSTMAN, etc., as well as via native clients available for many programming languages.

Let’s click on Query tab in the Solr Admin UI and it opens a query builder interface and click on search (Execute Query). As following:

solr searching

In this article, we have explained how to install and configure the Apache Solr into your machine and posting some indexes as well. But you can learn more about the Solr functionalities form here.

I hope now you can create Solr server in your machine.

Thanks for learning with the Dineshonjava.

Previous
Next