Install Apache Solr on Ubuntu

Chưa phân loại
In this quick post, we will see how we can install one of the most popular distributed free-text search databases, Apache Solr on Ubuntu and start using it as well. We will get started now .Read posts about Neo4J, Elasticsearch and MongoDB as well.

Apache Solr

Apache Solr is one of the most popular NoSQL databases which can be used to store data and query it in near real-time. It is based on Apache Lucene and is written in Java. Just like Elasticsearch, it supports database queries through REST APIs. This means that we can use simple HTTP calls and use HTTP methods like GET, POST, PUT, DELETE etc. to access data. It also provides an option to get in form of XML or JSON through the REST APIs.

In this lesson, we will study how to install Apache Solr on Ubuntu and start working with it through a basic set of Database queries.

Installing Java

To install Solr on Ubuntu, we must install Java first. Java might not be installed by default. We can verify it by using this command:

java -version

When we run this command, we get the following output:

We will now install Java on our system. Use this command to do so:

sudo add-apt-repository ppa:webupd8team/java
sudo apt-get update
sudo apt-get install oracle-java8-installer

Once these commands are done running, we can again verify that Java is now installed by using the same command.

Installing Apache Solr

We will now start with installing Apache Solr which is actually just a matter of a few commands.

To install Solr, we must know that Solr doesn’t work and run on its own, rather, it needs a Java Servlet container to run, for example, Jetty or Tomcat Servlet containers. In this lesson, we will be using Tomcat server but using Jetty is fairly similar.

The good thing about Ubuntu is that it provides three packages with which Solr can be easily installed and started. They are:

  • solr-common
  • solr-tomcat
  • solr-jetty

It is self-descriptive that solr-common is needed for both containers whereas solr-jetty is needed for Jetty and solr-tomcat is needed only for Tomcat server. As we have already installed Java, we can download the Solr package using this command:

sudo wget

As this package brings a lot of packages with it including Tomcat server as well, this can take a few minutes to download and install everything. Download the latest version of Solr files from here.

Once the installation has completed, we can unzip the file using the following command:

unzip -q

Now, change your directory into the zip file and you will see the following files inside:

Starting Apache Solr Node

Now that we have downloaded Apache Solr packages on our machine, we can do more as a developer from a node interface, so we will start a node instance for Solr where we can actually make collections, store data and make searchable queries.

Run the following command to start cluster setup:

./bin/solr start -e cloud

We will see the following output with this command:

Many questions will be asked but we will setup a single node Solr cluster with all of the default configuration. As shown in the final step, Solr node interface will be available at:


where 8983 is the default port for the node. Once we visit above URL, we will see the Node interface:

Using Collections in Solr

Now that our node interface is up and running, we can create a collection using the command:

./bin/solr create_collection -c linux_hint_collection

and we will see the following output:

Avoid the warnings for now. We can even see the collection in Node interface as well now:

Now, we can start by defining a schema in Apache Solr by selecting the schema section:

We can now start inserting data into our collections. Let’s insert a JSON document into our collection here:

curl -X POST -H ‘Content-Type: application/json’
‘http://localhost:8983/solr/linux_hint_collection/update/json/docs’ –data-binary
"id": "iduye",
"name": "Shubham"

We will see a success response against this command:

As a final command, let us see how we can GET all data from Solr collection:

curl http://localhost:8983/solr/linux_hint_collection/get?id=iduye

We will see the following output:

ONET IDC thành lập vào năm 2012, là công ty chuyên nghiệp tại Việt Nam trong lĩnh vực cung cấp dịch vụ Hosting, VPS, máy chủ vật lý, dịch vụ Firewall Anti DDoS, SSL… Với 10 năm xây dựng và phát triển, ứng dụng nhiều công nghệ hiện đại, ONET IDC đã giúp hàng ngàn khách hàng tin tưởng lựa chọn, mang lại sự ổn định tuyệt đối cho website của khách hàng để thúc đẩy việc kinh doanh đạt được hiệu quả và thành công.
Bài viết liên quan

VRChat for Linux

VRChat is a massive multiplayer online virtual reality platform launched in 2017 by VRChat Inc. The game was initially...

Bash tr command

tr is a very useful UNIX command. It is used to transform string or delete characters from the string. Various type of...

[CentOS 8] Hướng dẫn đặt IP trong CentOS 8 bằng nmcli

Trong các phiên bản từ CentOS 7 trở đi, gói NetworkManager đã cung cấp lệnh nmcli để thao tác việc...
Bài Viết

Bài Viết Mới Cập Nhật

Mua Proxy V6 Nuôi Facebook Spam Hiệu Quả Tại Onetcomvn

Hướng dẫn cách sử dụng ProxyDroid để duyệt web ẩn danh

Mua proxy Onet uy tín tại

Thuê mua IPv4 giá rẻ, tốc độ nhanh, uy tín #1

Thuê địa chỉ IPv4 IPv6 trọn gói ở đâu chất lượng, giá RẺ nhất?