Indexing

search_indexes.py

from haystack import indexes
from search.collection.models import Document
 
 
class CollectionIndex(indexes.SearchIndex, indexes.Indexable):
    text = indexes.CharField(document=True, use_template=True)
    name = indexes.CharField(model_attr='name')
    description = indexes.CharField(model_attr='description')
 
    def get_model(self):
        return Document
 
    def index_queryset(self, using=None):
        return self.get_model().objects.all()

  • Last modified: 2020/03/25 17:15