Permalink
Browse files

search index for haystack 2.0

  • Loading branch information...
philippWassibauer committed Jan 3, 2012
1 parent 6dbc14b commit fdb5b22d1895a9919b67a05072320521df528918
Showing with 7 additions and 24 deletions.
  1. +7 −24 threaded_messages/search_indexes.py
@@ -1,35 +1,18 @@
-from haystack.indexes import *
-from haystack import site
+from haystack import indexes
from models import Thread
-class ThreadIndex(RealTimeSearchIndex):
- text = CharField(document=True, use_template=True)
- participants = MultiValueField()
- last_message = DateTimeField(model_attr='latest_msg__sent_at')
+class ThreadIndex(indexes.SearchIndex, indexes.Indexable):
+ text = indexes.CharField(document=True, use_template=True)
+ participants = indexes.MultiValueField()
+ last_message = indexes.DateTimeField(model_attr='latest_msg__sent_at')
def index_queryset(self):
return Thread.objects.all()
def prepare_participants(self, object):
return [p.user.pk for p in object.participants.all()]
-site.register(Thread, ThreadIndex)
+ def get_model(self):
+ return Thread
-#from haystack import indexes
-#from models import Thread
-#
-#class ThreadIndex(indexes.SearchIndex, indexes.Indexable):
-# text = indexes.CharField(document=True, use_template=True)
-# participants = indexes.MultiValueField()
-# last_message = indexes.DateTimeField(model_attr='latest_msg__sent_at')
-#
-# def index_queryset(self):
-# return Thread.objects.all()
-#
-# def prepare_participants(self, object):
-# return [p.user.pk for p in object.participants.all()]
-#
-# def get_model(self):
-# return Thread
-#

0 comments on commit fdb5b22

Please sign in to comment.