Skip to content

Commit

Permalink
Adds a search index for haystack.
Browse files Browse the repository at this point in the history
  • Loading branch information
BertrandBordage committed Aug 12, 2012
1 parent 2aac3ce commit 9dfbb4f
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 1 deletion.
2 changes: 1 addition & 1 deletion MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
include README.rst COPYING
recursive-include terms *.html *.po *.mo
recursive-include terms *.html *.po *.mo *.txt
2 changes: 2 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ Optional
(tested with 1.6.0) to recover changes and deletions;
* `django-CMS <https://www.django-cms.org/>`_ (tested with 2.3),
because django-terms has an apphook and a menu.
* `django-haystack <http://haystacksearch.org/>`_ (tested with 2.0.0-beta)
because django-terms has a search index.



Expand Down
11 changes: 11 additions & 0 deletions terms/search_indexes.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
from haystack.indexes import RealTimeSearchIndex , Indexable, \
CharField, EdgeNgramField
from .models import Term


class TermIndex(RealTimeSearchIndex, Indexable):
text = CharField(document=True, use_template=True)
content_auto = EdgeNgramField(model_attr='name')

def get_model(self):
return Term
2 changes: 2 additions & 0 deletions terms/templates/search/indexes/terms/term_text.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
{{ term.name }}
{{ term.definition }}

0 comments on commit 9dfbb4f

Please sign in to comment.