Getting started with django-haystack

Other topics

Remarks:

This section provides an overview of what django-haystack is, and why a developer might want to use it.

It should also mention any large subjects within django-haystack, and link out to the related topics. Since the Documentation for django-haystack is new, you may need to create initial versions of those related topics.

Additional Info:

VersionRelease Date
2.5.12016-10-28
2.5.02016-07-12
2.4.12015-10-29
2.4.02015-06-09
2.3.22015-11-11
2.3.12014-09-22
2.3.02014-09-19
2.2.12014-09-03
2.2.02015-08-03
2.1.02013-07-28
2.0.02013-05-12

Installation or Setup

Installing the haystack package

pip install django-haystack

Configuration

Add haystack to your project's INSTALLED_APPS inside of your settings.py file:

# settings.py
INSTALLED_APPS = [
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',

    # Put haystack with above your project's apps
    'haystack',
    
    'myproject_app',
]

Now add the settings for your search backend. Haystack currently supports: solr, elasticsearch, whoosh, and xapian.

Solr:

HAYSTACK_CONNECTIONS = {
    'default': {
        'ENGINE': 'haystack.backends.solr_backend.SolrEngine',
        'URL': 'http://127.0.0.1:8983/solr'
        # ...or for multicore...
        # 'URL': 'http://127.0.0.1:8983/solr/mysite',
    },
}

Elasticsearch:

HAYSTACK_CONNECTIONS = {
    'default': {
        'ENGINE': 'haystack.backends.elasticsearch_backend.ElasticsearchSearchEngine',
        'URL': 'http://127.0.0.1:9200/',
        'INDEX_NAME': 'haystack',
    },
}

Whoosh:

import os

HAYSTACK_CONNECTIONS = {
    'default': {
        'ENGINE': 'haystack.backends.whoosh_backend.WhooshEngine',
        'PATH': os.path.join(os.path.dirname(__file__), 'whoosh_index'),
    },
}

Xapian:

import os

HAYSTACK_CONNECTIONS = {
    'default': {
        'ENGINE': 'xapian_backend.XapianEngine',
        'PATH': os.path.join(os.path.dirname(__file__), 'xapian_index'),
    },
}

Contributors

Topic Id: 3145

Example Ids: 10716

This site is not affiliated with any of the contributors.