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.
There are following system requirements for installing the Apache Solr into your machine.
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.
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.
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:
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.
To launch Solr, run: bin/solr start on Unix or MacOS; and bin\solr.cmd start on Windows. As following screenshot:
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,
Use the following command to launch the Solr in SolrCloud mode in your Linux or MacOS machine.
bin/solr start -e cloud
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:
Let’s create collections in the Solr.
You can use the following command to create collections in the Solr server.
bin\solr create -c Book
Let’s see the following diagram:
Similarly you can create some more collections such as Order, Product and verify them on the Solr Core Admin as following diagram:
After creating collections, let’s move to index these 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.
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/*
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:
After indexing Solr Collections, let’s move to next section to basic searching functionality.
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:
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.
Strategy Design Patterns We can easily create a strategy design pattern using lambda. To implement…
Decorator Pattern A decorator pattern allows a user to add new functionality to an existing…
Delegating pattern In software engineering, the delegation pattern is an object-oriented design pattern that allows…
Technology has emerged a lot in the last decade, and now we have artificial intelligence;…
Managing a database is becoming increasingly complex now due to the vast amount of data…
Overview In this article, we will explore Spring Scheduler how we could use it by…