Blog

The Digital Agency for International Development

Introducing ElasticStack

By Chris Wilson on 30 June 2014

ElasticStack is a small Django app that adds some very useful features when developing applications with Django, Haystack and ElasticSearch. It also has good documentation and tests. Please consider adding it to your application when you add ElasticSearch.

Configurable index mapping

Haystack's ElasticSearch backend includes brief but sensible defaults for nGram analysis. However it doesn't allow you to override these defaults, except by creating a new backend class. ElasticStack makes that possible.

Field based analysis

Even with a new default analyzer you may want to change this on a field by field basis as fits your needs. ElasticStack makes that possible.

Django CBV style views

Haystacks's class based views predate the inclusion of CBVs into the Django core and so the paradigms are different. This makes it harder to impossible to make use of view mixins. Haystack includes a SearchView, which looks like a standard class-based view but it's not: it has a different interface and it's not thread-safe by itself:

The standard SearchView is not thread-safe. Use the search_view_factory function, which returns thread-safe instances of SearchView.

ElasticStack gives you some nice class-based views to use, which behave as you'd expect and are thread safe.

show_mapping management command

Make a change and wonder why your results don't look as expected? The management command show_mapping will print the current mapping for your defined search index(es). It may show that you've simply forgotten to update your index with new mappings.

show_document management command

Provided the name of an indexed model and a key it generates and prints the generated JSON document for this object, so you can see what goes into the search engine.

More information

Please read the README file for more information about these features, which I've only summarised here.