Haystack + ElasticSearch

Haystack + ElasticSearch

3c23eb6a8e08c10663c054e5f3432899?s=128

Gilang Chandrasa

June 29, 2013
Tweet

Transcript

  1. Haystack + ElasticSearch Gilang Chandrasa

  2. Django Python PHP ElasticSearch HTML5 Memcache MongoDB Celery NginX Android

    Git MySQL PostgreSQL Gilang Chandrasa CSS3
  3. Haystack Why What How

  4. A modular search for Django

  5. lets you write your search code once and choose the

    search engine you want it to run on
  6. lets you write your search code once and choose the

    search engine you want it to run on Solr, Elasticsearch, Whoosh and Xapian
  7. pip install django-haystack Step 1 Install Haystack

  8. INSTALLED_APPS = [ ... 'haystack', ] HAYSTACK_CONNECTIONS = { 'default':

    { 'ENGINE': '...', }, } Step 2 Configure settings.py
  9. class NoteIndex(indexes.SearchIndex, indexes.Indexable): text = indexes.CharField(document=True, use_template=True) author = indexes.CharField(model_attr='user')

    def get_model(self): return Note Step 3 Create search_index.py
  10. {{ object.title }} {{ object.user.get_full_name }} {{ object.body }} Step

    4 Create search template
  11. Step 5 Install Search Engine Solr Xapian Whoosh ElasticSearch

  12. Step 6 Indexing python manage.py rebuild_index

  13. Some Advanced Uses Highlighting Autocomplete Boost Rich Content Extraction Spatial

    Search
  14. ElasticSearch

  15. ElasticSearch distributed real-time search and analytics engine for the cloud

  16. real time data real time analytics distributed high availability multi

    tenancy full text search document oriented conflict management schema free restful API apache 2 open source license per operation persistence built on top apache lucene
  17. Spatial Search within, dwithin, distance, order_by(‘distance’), polygon

  18. location = Point(float(longitude), float(latitude)) SearchQuerySet()\ .dwithin('location', location,D(km=10))\ .distance('location',location)\ .order_by('distance') Search

    places within 10km and order by distance
  19. haystacksearch.org elasticsearch.org Further Reading

  20. thank you!

  21. Gilang Chandrasa twitter.com + github.com @gchandrasa