Skip to content
Create a gist now

Instantly share code, notes, and snippets.

Embed URL


Subversion checkout URL

You can clone with
Download ZIP
# -*- coding: UTF-8 -*-
from haystack import indexes
from ewebapp.apps.articles.models import Article, Category
from ewebapp.apps.utils.strings import remove_accents
class ArticleIndex(indexes.SearchIndex, indexes.Indexable):
text = indexes.CharField(document=True, use_template=True)
title = indexes.CharField(model_attr='title')
keywords = indexes.MultiValueField()
suggestions = indexes.FacetCharField()
def get_model(self):
return Article
def prepare(self, obj):
prepared_data = super(ArticleIndex, self).prepare(obj)
prepared_data['suggestions'] = prepared_data['text']
return prepared_data
def prepare_text(self, obj):
if not obj.body:
return u''
return remove_accents(obj.body.lower())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.