1
from haystack import indexes
2
from wlhelp.models import Worker, Ware, Building
3
from haystack.fields import DateField
4
from datetime import date
7
class WorkerIndex(indexes.SearchIndex, indexes.Indexable):
9
"""Create a search index. Changes made here need to be reindexed. Defined
10
fields are stored in the index, so when displaying the result the data is
11
read from the index and do not hit the database.
13
Except the 'text' field all defined fields will be in the index.
15
'text' indicates the template where the concatenated data
16
is gathered and the search runs over.
20
text = indexes.CharField(document=True, use_template=True)
21
# To get date related search working
22
# we assume the index is always up to date
23
date = DateField(default=date.today())
24
displayname = indexes.CharField(model_attr='displayname')
25
help = indexes.CharField(model_attr='help')
30
class WareIndex(indexes.SearchIndex, indexes.Indexable):
32
text = indexes.CharField(document=True, use_template=True)
33
# To get date related search working
34
# we assume the index is always up to date
35
date = DateField(default=date.today())
36
displayname = indexes.CharField(model_attr='displayname')
37
help = indexes.CharField(model_attr='help')
42
class BuildingIndex(indexes.SearchIndex, indexes.Indexable):
44
text = indexes.CharField(document=True, use_template=True)
45
# To get date related search working
46
# we assume the index is always up to date
47
date = DateField(default=date.today())
48
displayname = indexes.CharField(model_attr='displayname')
49
help = indexes.CharField(model_attr='help')