I'm using Haystack and Whoosh with Django and I was trying to create the indexes through the code below:
class LivroIndex(SearchIndex):
text = CharField(document=True, use_template=True)
autor = CharField(model_attr='Autor')
titulo = CharField(model_attr='Titulo')
datalivro = DateTimeField(model_attr='DataLivro')
def index_queryset(self):
return Livro.objects.filter(DataLivro__lte=datetime.datetime.now())
def prepare(self, obj):
self.prepared_data = super(LivroIndex, self).prepare(obj)
self.prepared_data['text'] = obj.Autor
return self.prepared_data
Livro is a class in my models file.
In this way, you can use only "autor" as a field which users can use to search content inside the application. Is there any other ways to make it accept more than one field?
Thanks in advance!