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.
In previous part, we installed Elasticsearch and Kibana. Now we will create a Django project and will link the elastic search with the project.
You can follow the official Django tutorials to create and start a Django project. Or you follow below steps. We will be following the official documentation, but only the necessary steps.
– Make sure python 3 is installed on your machine. Although not mandatory but it is recommended to use virtual environment.
– Install Django. Setup a database. We will be using MySQL.
– Create a project.
$ django-admin startproject elasticsearchdjango
– Change directory to elasticsearch. Create a new app ‘poll’.
$ python manage.py startapp polls
– If you are using virtual environment than install the dependencies using
pip install -r req.txt file after saving below lines in
– Create a model in polls/models.py file.
from django.db import models
author = models.CharField(max_length=100)
question_text = models.CharField(max_length=1000)
pub_date = models.DateTimeField('date published')
Continue reading “Elastic Search with Kibana and Django – part 2”