Please note I am using elasticsearch as my backend.
Taggit tags associated with my model, ObjectA, do not seem to come through in my index using the django setting
HAYSTACK_SIGNAL_PROCESSOR = 'haystack.signals.RealtimeSignalProcessor'
When I list the index documents using
http://localhost:9200/_search
and view the index record for an ObjectA instance I inserted in the DB the 'tags' element appears as
"tags": []
It is only after I run
manage.py rebuild_index [or update_index]
do the tags appear i.e.
"tags": ["tag-a", "tag-b"]
The interesting thing is 'title', 'description' show-up automatically without running rebuild_index/update_index.
objecta_text.txt
{{ object.title }}
{{ object.description }}
{% for tag in object.tags.all %} {{ tag.name }} {% endfor %}
search_indexes.py
class ObjectAIndex(indexes.SearchIndex, indexes.Indexable):
text = indexes.CharField(document=True, use_template=True)
title = indexes.CharField(model_attr='title')
description = indexes.CharField(model_attr='description', null=True)
tags = indexes.MultiValueField()
def get_model(self):
return ObjectA
def prepare_tags(self, obj):
return [tag.name for tag in obj.tags.all()]
Any suggestions on how to get the tags to show up in the index document without invoking rebuild_index?