How to Index and Query Data With Haystack and Elasticsearch in Python

, , Comments Off on How to Index and Query Data With Haystack and Elasticsearch in Python

Haystack is a Python library that provides modular search for Django. It features an API that provides support for different search back ends such as Elasticsearch, Whoosh, Xapian, and Solr.

Elasticsearch is a popular Lucene search engine capable of full-text search, and it’s developed in Java.

Google search uses the same approach of indexing their data, and that’s why it’s very easy to retrieve any information with just a few keywords, as shown below.

Elastic Search and Google

The first step is to get Elasticsearch up and running locally on your machine. Elasticsearch requires Java, so you need to have Java installed on your machine.

We are going to follow the instructions from the Elasticsearch site.

Download the Elasticsearch 1.4.5 tar as follows:

Extract it as follows:

It will then create a batch of files and folders in your current directory. We then go into the bin directory as follows:

Start Elasticsearch as follows.

To confirm if it has installed successfully, go to http://127.0.0.1:9200/, and you should see something like this.

Ensure you also have haystack installed.

Read ful tutorial at code.tutsplus