blob: 0037d5be783ade1e1e6ae2defaad29d6acbefca6 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
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()
|