diff options
Diffstat (limited to '97suifangqa/apps/sciblog/search_indexes.py')
-rw-r--r-- | 97suifangqa/apps/sciblog/search_indexes.py | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/97suifangqa/apps/sciblog/search_indexes.py b/97suifangqa/apps/sciblog/search_indexes.py new file mode 100644 index 0000000..0037d5b --- /dev/null +++ b/97suifangqa/apps/sciblog/search_indexes.py @@ -0,0 +1,35 @@ +# -*- coding: utf-8 -*- +from haystack import indexes +import datetime +from .models import SciBlog, BlogAnnotation + + +class SciBlogIndex(indexes.SearchIndex, indexes.Indexable): + u''' + 科学文章索引 + ''' + text = indexes.CharField(document=True, use_template=True) + + def get_model(self): + return SciBlog + + def index_queryset(self, using=None): + u''' + 对所有文章进行索引 + ''' + return self.get_model().objects.all() + +class ProperNounIndex(indexes.SearchIndex, indexes.Indexable): + u''' + 专业名词索引 + ''' + text = indexes.CharField(document=True, use_template=True) + + def get_model(self): + return BlogAnnotation + + def index_queryset(self, using=None): + u''' + 返回所有类型为专业名词类型的注释 + ''' + return self.get_model().objects.propernouns() |