Skip to content

@catalanojuan /search_index.py secret
Created

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Index
# -*- 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.