search_indexes.py 693 Bytes
Newer Older
1 2 3 4 5 6 7
from haystack import indexes
from models import Operator, Violation

class ViolationIndexes(indexes.SearchIndex, indexes.Indexable):
    text = indexes.CharField(document=True, use_template=True)
    operator = indexes.CharField(model_attr="operator_ref")
    country = indexes.CharField(model_attr="country")
8 9 10
    contract = indexes.CharField(model_attr="contract")
    type = indexes.CharField(model_attr="contractual")
    media = indexes.CharField(model_attr="media")
Okhin's avatar
Okhin committed
11
    operator_name = indexes.CharField()
12
    state = indexes.NgramField(model_attr="state")
13 14 15

    def get_model(self):
        return Violation
Okhin's avatar
Okhin committed
16 17 18

    def prepare_operator_name(self, obj):
        return obj.operator_ref.name