| 1 |
================== |
| 2 |
celery-haystack-ng |
| 3 |
================== |
| 4 |
|
| 5 |
This Django app allows you to utilize Celery for automatically updating and |
| 6 |
deleting objects in a Haystack_ search index. |
| 7 |
|
| 8 |
Forked from the original celery-haystack_. |
| 9 |
|
| 10 |
Requirements |
| 11 |
------------ |
| 12 |
|
| 13 |
* Django 2.1+ |
| 14 |
* Haystack_ 2.X+ |
| 15 |
* Celery_ 4.X+ |
| 16 |
|
| 17 |
You also need to install your choice of one of the supported search engines |
| 18 |
for Haystack and one of the supported backends for Celery. |
| 19 |
|
| 20 |
|
| 21 |
.. _Haystack: http://haystacksearch.org |
| 22 |
.. _celery-haystack: https://github.com/django-haystack/celery-haystack |
| 23 |
|
| 24 |
|
| 25 |
Installation |
| 26 |
------------ |
| 27 |
|
| 28 |
Use your favorite Python package manager to install the app from PyPI, e.g.:: |
| 29 |
|
| 30 |
pip install celery-haystack-ng |
| 31 |
|
| 32 |
|
| 33 |
For Django < 1.9 you need to install and configure `django-transaction-hooks`_ -- an app that |
| 34 |
brings transaction commit hooks to Django. |
| 35 |
|
| 36 |
.. _django-transaction-hooks: https://github.com/carljm/django-transaction-hooks |
| 37 |
|
| 38 |
|
| 39 |
Usage |
| 40 |
----- |
| 41 |
|
| 42 |
1. Add ``'celery_haystack'`` to the ``INSTALLED_APPS`` setting |
| 43 |
|
| 44 |
.. code:: python |
| 45 |
|
| 46 |
INSTALLED_APPS = [ |
| 47 |
# .. |
| 48 |
'celery_haystack', |
| 49 |
] |
| 50 |
|
| 51 |
2. Enable the celery-haystack signal processor in the settings |
| 52 |
|
| 53 |
.. code:: python |
| 54 |
|
| 55 |
HAYSTACK_SIGNAL_PROCESSOR = 'celery_haystack.signals.CelerySignalProcessor' |
| 56 |
|
| 57 |
3. Alter all of your ``SearchIndex`` subclasses to inherit from |
| 58 |
``celery_haystack.indexes.CelerySearchIndex`` and |
| 59 |
``haystack.indexes.Indexable`` |
| 60 |
|
| 61 |
.. code:: python |
| 62 |
|
| 63 |
from haystack import indexes |
| 64 |
from celery_haystack.indexes import CelerySearchIndex |
| 65 |
from myapp.models import Note |
| 66 |
|
| 67 |
class NoteIndex(CelerySearchIndex, indexes.Indexable): |
| 68 |
text = indexes.CharField(document=True, model_attr='content') |
| 69 |
|
| 70 |
def get_model(self): |
| 71 |
return Note |
| 72 |
|
| 73 |
4. Ensure your Celery instance is running. |
| 74 |
|
| 75 |
Thanks |
| 76 |
------ |
| 77 |
|
| 78 |
This app is a blatant rip-off of Daniel Lindsley's queued_search_ |
| 79 |
app but uses Ask Solem Hoel's Celery_ instead of the equally awesome |
| 80 |
queues_ library by Matt Croyden. |
| 81 |
|
| 82 |
.. _queued_search: https://github.com/toastdriven/queued_search/ |
| 83 |
.. _Celery: http://celeryproject.org/ |
| 84 |
.. _queues: http://code.google.com/p/queues/ |
| 85 |
|
| 86 |
Issues |
| 87 |
------ |
| 88 |
|
| 89 |
Please use the `EduGit issue tracker`_ for any bug reports or feature |
| 90 |
requests. |
| 91 |
|
| 92 |
.. _`EduGit issue tracker`: https://edugit.org/AlekSIS/libs/celery-haystack-ng/-/issues |