Elastic Search with Kibana and Django

kibana, elastic search with Django

In this article we will see how to implement fast text search using elastic search instead of using MySQL or PostgreSQL.

System configurations:

– Ubuntu 16.04
– Python 3.5, Django 1.10
– Elastic Search v6.0.0
– Kibana v6.0.0

Elastic Search:

As per Wikipedia:

Elasticsearch is a search engine based on Lucene. It provides a distributed, multitenant-capable full-text search engine with an HTTP web interface and schema-free JSON documents.

ElasticSearch indexes documents for your data instead of using data tables like a regular relational database does.

There are two client libraries to interact with ElasticSearch with Python.
1. elasticsearch-py
2. elasticsearch-dsl

Installing Elastic Search:

Since ElasticSearch runs on Java you must ensure you have an updated JVM version. Check what version you have with java -version in the terminal.

1 – Make a directory.
mkdir elasticsearch

2 – Download the tar file.
wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-6.0.0.tar.gz

3 – Untar the compressed file.
tar -xzf elasticsearch-6.0.0.tar.gz

4 – Start the elastic search.
./elasticsearch-6.0.0/bin/elasticsearch

Elastic search will print lots of output on terminal.

starting elastic search

To confirm if its working, go to your browser and hit http://localhost:9200/ .  You will get the response something like below.

elastic search UI

Elastic search is up and running. Lets setup the Kibana.

Kibana:

Kibana is an open source analytics and visualization platform designed to work with Elasticsearch. Its simple, browser-based interface enables you to quickly create and share dynamic dashboards that display changes to Elasticsearch queries in real time.

Installing Kibana:

Official documentation of Kibana explains in detail about the steps to install it. We are going to present you the short version of same. We will be installing using the .deb file.

1 – Download the kibana v6.0.0 deb file.
wget https://artifacts.elastic.co/downloads/kibana/kibana-6.0.0-amd64.deb

2 – Compare the SHA produced by sha1sum or shasum with the published SHA.
sha1sum kibana-6.0.0-amd64.deb

3 – Install kibana.
sudo dpkg -i kibana-6.0.0-amd64.deb

Use below commands to start or stop kibana.

Use below commands to start kibana automatically when system boots up

Now open the Kibana in browser. Go to http://localhost:5601 . If your elastic search was running and everything is fine then you will see all green on the kibana status page otherwise you may see some red flags.

kibana elastic search error

So now kibana and elastic search are up, connected and running.

In next part of this article, we will setup a Django project and will link it to elastic search.

(Visited 2,524 times, 1 visits today)

You must read this :

4 thoughts on “Elastic Search with Kibana and Django”

Leave a Reply

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