Elastic Search with Kibana and 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.

elastic search with kibana and django


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

elastic search with kibana and django

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.

sudo systemctl start kibana.service 
sudo systemctl stop kibana.service


Use below commands to start kibana automatically when system boots up

sudo /bin/systemctl daemon-reload
sudo /bin/systemctl enable kibana.service


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.

elastic search with kibana and django


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.


Related Articles:
Python Script 3: Validate, format and Beautify JSON string Using Python
Validating json using python code, format and beautify json file using python, validate json file using python, how to validate, format and beautify json...
Encryption-Decryption in Python Django
How to encrypt and decrypt the content in DJango. Encrypting the critical information in Django App. Encrypting username, email and password in Django...
Adding Robots.txt file to Django Application
Adding robots.txt file in your Django application. Easiest way to add robots.txt file. Django application robots.txt file. Why should you add robots.txt file in your Django Application....
How to upgrade to paid account on PythonAnyWhere
Which is the best server for hosting Django Apps. Best hosting provider for Django Apps. Cheapest Django Hosting. PythonAnyWhere Reviews. Django Hosting....

0 thoughts on 'Elastic Search With Kibana And Django'
Leave a comment:


*All Fields are mandatory. **Email Id will not be published publicly.


SUBSCRIBE
Please subscribe to get the latest articles in your mailbox.



Recent Posts:





© pythoncircle.com 2018-2019