/celery-haystack

An app for integrating Celery with Haystack.

Primary LanguagePythonBSD 3-Clause "New" or "Revised" LicenseBSD-3-Clause

celery-haystack

Build Status

This Django app allows you to utilize Celery for automatically updating and deleting objects in a Haystack search index.

Requirements

You also need to install your choice of one of the supported search engines for Haystack and one of the supported backends for Celery.

Installation

Use your favorite Python package manager to install the app from PyPI, e.g.:

pip install celery-haystack

By default a few dependencies will automatically be installed:

Usage

Haystack 1.X

  1. Add 'celery_haystack' to the INSTALLED_APPS setting

    INSTALLED_APPS = [
        # ..
        'celery_haystack',
    ]
    
  2. Alter all of your SearchIndex subclasses to inherit from celery_haystack.indexes.CelerySearchIndex

    from haystack import site
    from celery_haystack.indexes import CelerySearchIndex
    from myapp.models import Note
    
    class NoteIndex(CelerySearchIndex):
        text = indexes.CharField(document=True, model_attr='content')
    
    site.register(Note, NoteIndex)
    
  3. Ensure your Celery instance is running.

Haystack 2.X

  1. Add 'celery_haystack' to the INSTALLED_APPS setting

    INSTALLED_APPS = [
        # ..
        'celery_haystack',
    ]
    
  2. Enable the celery-haystack signal processor in the settings

    HAYSTACK_SIGNAL_PROCESSOR = 'celery_haystack.signals.CelerySignalProcessor'
    
  3. Alter all of your SearchIndex subclasses to inherit from celery_haystack.indexes.CelerySearchIndex and haystack.indexes.Indexable

    from haystack import indexes
    from celery_haystack.indexes import CelerySearchIndex
    from myapp.models import Note
    
    class NoteIndex(CelerySearchIndex, indexes.Indexable):
        text = indexes.CharField(document=True, model_attr='content')
    
        def get_model(self):
            return Note
    
  4. Ensure your Celery instance is running.

Thanks

This app is a blatant rip-off of Daniel Lindsley's queued_search app but uses Ask Solem Hoel's Celery instead of the equally awesome queues library by Matt Croyden.

Issues

Please use the Github issue tracker for any bug reports or feature requests.