Beispiel #1
0
class JobIndex(indexes.SearchIndex, indexes.Indexable):
	text = indexes.CharField(document=True, use_template=True)
	author = indexes.CharField(model_attr='user')
	text = models.CharField(max_length=120, unique=True)
	pub_date = indexes.DateTimeField(model_attr='pub_date')

	def get_model(self):
		return Job

	def index_queryset(self, using=None):
    	"""Used when the entire index for model is updated."""
    	return self.get_model().objects.filter(pub_date__lte=datetime.datetime.now())
Beispiel #2
0
class Contactindex(indexes.SearchIndex, indexes.indexable):
    text = indexes.CharField(document=True, use_template=True)
    user_to = indexes.CharField(model_attr='user_to')
    pub_date = indexes.DateTimeField(model_attr='pub_date')

    def get_model(self):
        return Contact

    def index_queryset(self, using=None):
        """ Used when the entire index for model is updated"""
        return self.get_model().objects.filter(
            pub_date__lte=datetime.datetime.now())
Beispiel #3
0
class ProfileIndex(indexes.SearchIndex):

    profile = indexes.CharField(model_attr='user')
    date_of_birth = indexes.DateTimeField(model_attr='date_of_birth')

    def get_model(self):
        return Note

    def index_queryset(self, using=None):
        """Used when the entire index for model is updated."""
        return self.get_model().objects.filter(
            pub_date__lte=datetime.datetime.now())
Beispiel #4
0
class ArticleIndex(indexes.SearchIndex, indexes.Indexable):
    text = indexes.CharField(document=True, use_template=True)
    pub_date = indexes.DateTimeField(model_attr='pub_date')

    content_auto = indexes.EdgeNgramField(model_attr='title')

    def get_model(self):
        return Article

    def index_queryset(self, using=None):
        """Used when the entire index for model is updated."""
        return self.get_model().objects.all()
class UserIndex(indexes.SearchIndex, indexes.Indexable):
    text = indexes.CharField(document=True, use_template=False)
    date_joined = indexes.DateTimeField(model_attr='date_joined')
    username = indexes.CharField(model_attr='username')

    username_auto = indexes.EdgeNgramField(model_attr='username')

    def get_model(self):
        return User

    def index_queryset(self, using=None):
        return self.get_model().objects.filter(date_joined__lte=timezone.now())
Beispiel #6
0
class ArticleIndex(indexes.SearchIndex, indexes.Indexable):
    text = indexes.CharField(document=True, use_template=True)
    author = indexes.CharField(model_attr='author')
    create_date = indexes.DateTimeField(model_attr='create_date')

    def get_model(self):
        return Article

    def index_queryset(self, using=None):
        """Used when the entire index for model is updated."""
        return self.get_model().objects.filter(
            create_date__lte=datetime.datetime.now())
Beispiel #7
0
class PostIndex(indexes.SearchIndex, indexes.Indexable):
	"""post索引, 告知haystack那些数据需要被编入搜索索引"""
	# 主要搜索字段
	text = indexes.CharField(document=True, use_template=True)
	# 参数代表, 该索引对应Post的publish字段
	publish = indexes.DateTimeField(model_attr="publish")

	def get_model(self):
		return Post

	def index_queryset(self, using=None):
		return self.get_model().published.all()
class NoteIndex(indexes.SearchIndex, indexes.Indexable):
    text = indexes.CharField(document=True, use_template=True)
    author = indexes.CharField(model_attr='user')
    pub_date = indexes.DateTimeField(model_attr='pub_date')
    title = indexes.CharField(model_attr='title', boost=1.125)

    def get_model(self):
        return Note

    def index_queryset(self, using=None):
        """Used when the entire index for model is updated."""
        return self.get_model().objects.all()
Beispiel #9
0
class NoteIndex(indexes.SearchIndex, indexes.Indexable):
    text = indexes.CharField(document=True, use_template=True)
    pub_date = indexes.DateTimeField(model_attr='pub_date')
    authors = indexes.CharField(model_attr='user')
    content_auto = indexes.EdgeNgramField(model_attr='content')

    def get_model(self):
        return Note

    def index_queryset(self, using=None):
        return self.get_model().objects.filter(
            pub_date__lte=datetime.datetime.now())
Beispiel #10
0
class TorrentDataIndex(indexes.SearchIndex, indexes.Indexable):
    text = indexes.CharField(document=True, use_template=True)
    pub_date = indexes.DateTimeField(model_attr='pub_date')

    def get_model(self):
        return TorrentData

    def index_queryset(self, using=None):
        return self.get_model().objects.all()

    def get_updated_field(self):
        return "pub_date"
Beispiel #11
0
class MovieIndex(indexes.SearchIndex, indexes.Indexable):
    text = indexes.CharField(document=True, use_template=True)
    title = indexes.CharField(model_attr='title')
    director = indexes.CharField(model_attr='director')
    release_date = indexes.DateTimeField(model_attr='release_date')

    def get_model(self):
        return Movie

    def index_queryset(self, using=None):
        return self.get_model().objects.filter(
            release_date__lte=datetime.datetime.now())
class PostsIndex(indexes.SearchIndex, indexes.Indexable):
    text = indexes.NgramField(document=True, use_template=False)
    user = indexes.CharField(model_attr='author')
    create_time = indexes.DateTimeField(model_attr='create_time')

    def get_model(self):  #获取模块
        return Posts

    def index_queryset(self, using=None):
        """Used when the entire index for model is updated."""
        return self.get_model().objects.filter(
            create_time=datetime.datetime.now())
class PostIndex(indexes.SearchIndex):
    text = indexes.CharField(document=True, use_template=True)
    author = indexes.CharField(model_attr='user')
    pub_date = indexes.DateTimeField(model_attr='pub_date')

    def get_queryset(self):
        "Used when the entire index for model is updated."
        return Post.objects.published()

    def should_update(self, instance, **kwargs):
        created = kwargs.get('created',False)
        return created
Beispiel #14
0
class PostIndex(indexes.SearchIndex, indexes.Indexable):

    text = indexes.CharField(document=True, use_template=True)
    publish = indexes.DateTimeField(model_attr='publish')

    def get_model(self):
        # What class will be indexed
        return Post

    # indexing range for Post object. We will include all published posts
    def index_queryset(self, using=None):
        return self.get_model().published.all()
Beispiel #15
0
class HostelNoticeIndex(indexes.SearchIndex, indexes.Indexable):
    text = indexes.CharField(document=True, use_template=True)
    notice_type = indexes.CharField(model_attr='hall_type')
    date = indexes.DateTimeField(model_attr='date')

    def get_model(self):
        return HostelNotice

    def index_queryset(self, using=None):
        """Used when the entire index for model is updated."""
        return self.get_model().objects.filter(
            date__lte=datetime.datetime.now())
Beispiel #16
0
class QuestionIndex(indexes.SearchIndex, indexes.Indexable):
    text = indexes.CharField(document=True, use_template=True)
    # text = indexes.CharField(model_attr='subject')
    author = indexes.CharField(model_attr='author')
    created_at = indexes.DateTimeField(model_attr='created_at')

    def get_model(self):
        return Question

    def index_queryset(self):
        """Used when the entire index for model is updated."""
        return self.get_model().objects.all()
Beispiel #17
0
class RecipeIndex(indexes.SearchIndex, indexes.Indexable):
    text = indexes.CharField(document=True, use_template=True)
    name_bm = indexes.CharField(model_attr="name_bm")
    created_date = indexes.DateTimeField(model_attr="created_date")

    def get_model(self):
        return Recipe

    def index_queryset(self, using=None):
        """Used when the entire index for model is updated."""
        return self.get_model().objects.filter(
            created_date_lte=datetime.datetime.now())
Beispiel #18
0
class AnswerIndex(CelerySearchIndex, indexes.Indexable):
    text = indexes.CharField(document=True, use_template=True)
    author = indexes.CharField(model_attr='author')
    created_at = indexes.DateTimeField(model_attr='created_at')
    place = indexes.CharField(model_attr='question__entity__slug')

    def get_model(self):
        return Answer

    def index_queryset(self, **kwargs):
        """Used when the entire index for model is updated."""
        return self.get_model().objects.all()
Beispiel #19
0
class PostIndex(indexes.SearchIndex, indexes.Indexable):
    # this field is primary search field
    text = indexes.CharField(document=True, use_template=True)
    # publish field is a datetime field that will also be indexed
    # corresponds to publish field of post model
    publish = indexes.DateTimeField(model_attr='publish')

    def get_model(self):
        return Post

    def index_queryset(self, using=None):
        return self.get_model().published.all()
Beispiel #20
0
class EventIndex(indexes.SearchIndex, indexes.Indexable):
    text = indexes.CharField(document=True, use_template=True)
    autosuggest = indexes.EdgeNgramField(model_attr='name')
    start_time = indexes.DateTimeField(model_attr='start_time')
    end_time = indexes.DateTimeField(model_attr='end_time')

    def get_updated_field(self):
        return 'last_modified_time'

    def get_model(self):
        return Event

    def prepare(self, obj):
        #obj.lang_keywords = obj.keywords.filter(language=get_language())
        if obj.description:
            obj.description = strip_tags(obj.description)
        return super(EventIndex, self).prepare(obj)

    def index_queryset(self, using=None):
        return self.get_model().objects.filter(
            publication_status=PublicationStatus.PUBLIC, deleted=False)
Beispiel #21
0
class NoteIndex(indexes.SearchIndex, indexes.Indexable):
    text = indexes.CharField(document=True, use_template=True)
    author = indexes.CharField(model_attr='user')
    pub_date = indexes.DateTimeField(model_attr='pub_date')

    def get_model(self):
        return Note

    def index_queryset(self):
        """Used when the entire index for model is updated."""
        print self.get_model().objects.filter(pub_date__lte=datetime.datetime.now())
        return self.get_model().objects.filter(pub_date__lte=datetime.datetime.now())
Beispiel #22
0
class MyuserIndex(indexes.SearchIndex, indexes.Indexable):

    text = indexes.CharField(document=True, use_template=True)
    username = indexes.CharField(model_attr = 'username')
    something = indexes.CharField(model_attr = 'something')
    date_join = indexes.DateTimeField(model_attr = 'date_join')

    def get_model(self):
        return MyUser

    def index_queryset(self, using = None):
        return self.get_model().objects.filter(date_join__lte = datetime.now())
Beispiel #23
0
class ArticleIndex(indexes.SearchIndex, indexes.Indexable):
    """Article search index model"""

    text = indexes.CharField(document=True, use_template=True)
    category = indexes.CharField(model_attr="category", null=True)
    published_at = indexes.DateTimeField(model_attr="published_at")

    def get_model(self):
        return Article

    def index_queryset(self, using=None):
        return self.get_model().published.all()
Beispiel #24
0
class BlogIndex(indexes.SearchIndex, indexes.Indexable):
    """
    Search index for blog entries
    """
    title = indexes.CharField(model_attr='title')
    content = indexes.CharField(model_attr='content')
    created_date = indexes.DateTimeField(model_attr='created_date')
    text = indexes.CharField(document=True, use_template=True)

    def get_model(self):
        """Return corresponding model"""
        return BlogPost
Beispiel #25
0
class ProblemIndex(indexes.SearchIndex, indexes.Indexable):
    text = indexes.EdgeNgramField(document=True, use_template=True)
    date = indexes.DateTimeField(model_attr='updated_on')

    def get_model(self):
        return Problem

    def index_queryset(self, using=None):
        return self.get_model().objects.filter(state=Problem.PUBLISHED)

    def get_updated_field(self):
        return None
class CommentIndex(indexes.SearchIndex, indexes.Indexable):
    text = indexes.EdgeNgramField(document=True, model_attr='comment')
    date = indexes.DateTimeField(model_attr='submit_date')

    def get_model(self):
        return Comment

    def index_queryset(self, using=None):
        return self.get_model().objects.filter(submit_date__lte=datetime.datetime.now())

    def get_updated_field(self):
        return 'submit_date'
class PostIndex(indexes.SearchIndex, indexes.Indexable):
    text = indexes.EdgeNgramField(document=True, use_template=True, template_name='search/informations_text.txt')
    writer = indexes.CharField(model_attr='user')
    pub_date = indexes.DateTimeField(model_attr='last_modified')
    content_auto = indexes.EdgeNgramField(model_attr='title')

    def get_model(self):
        return Post

    def index_queryset(self, using=None):
        """Used when the entire index for model is updated."""
        return self.get_model().objects.all()
Beispiel #28
0
class ArticleIndex(indexes.SearchIndex, indexes.Indexable):
    text = indexes.CharField(
        document=True,
        use_template=True,
    )

    created = indexes.DateTimeField(model_attr='created', )
    entry = indexes.MultiValueField()
    article = indexes.MultiValueField()

    def get_model(self):
        return Comments
Beispiel #29
0
class NoteIndex(indexes.SearchIndex, indexes.Indexable):
    text = indexes.CharField(document=True, use_template=True)
    title = indexes.CharField(model_attr='title')
    last_update_time = indexes.DateTimeField(model_attr='last_update_time')

    def get_model(self):
        return TestCase

    def index_queryset(self, using=None):
        """Used when the entire index for model is updated."""
        return self.get_model().objects.filter(
            last_update_time__lte=datetime.datetime.now())
Beispiel #30
0
class PostSearchIndex(indexes.SearchIndex, indexes.Indexable):
    text = indexes.CharField(document=True, use_template=True)

    title = indexes.CharField(indexed=False, model_attr='title')
    url = indexes.CharField(indexed=False, model_attr='get_absolute_url')
    publish_date = indexes.DateTimeField(model_attr='publish_date')

    def get_model(self):
        return Post

    def index_queryset(self, using=None):
        return self.get_model().objects.latest_public()