In this article we will see how to implement fast text search using elastic search instead of using MySQL or PostgreSQL.
- Ubuntu 16.04
- Python 3.5, Django 1.10
- Elastic Search v6.0.0
- Kibana v6.0.0
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.
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.
2 - Download the tar file.
3 - Untar the compressed file.
tar -xzf elasticsearch-6.0.0.tar.gz
4 - Start the elastic search.
Elastic search will print lots of output on terminal.
To confirm if its working, go to your browser and hit
http://localhost:9200/ . You will get the response something like below.
Elastic search is up and running. Lets setup the 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.
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.
2 - Compare the SHA produced by sha1sum or shasum with the published SHA.
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.
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.