スペルチェックで None を取得しています
最初にsettings.pyを変更しました
HAYSTACK_CONNECTIONS = {
'default': {
'ENGINE': 'haystack.backends.solr_backend.SolrEngine',
'URL': 'http://127.0.0.1:8983/solr',
'INCLUDE_SPELLING': True,
},
}
search_indexes.py に変更を加えました
class JobIndex(indexes.SearchIndex, indexes.Indexable):
text = indexes.CharField(document=True, use_template=True)
post_type = indexes.CharField(model_attr='post_type',faceted=True)
job_location = indexes.CharField(model_attr='job_location',faceted=True)
job_type = indexes.CharField(model_attr='job_type',faceted=True)
company_name = indexes.CharField(model_attr='company_name',faceted=True)
job_title = indexes.CharField(model_attr='job_title', faceted=True)
start_date = indexes.DateField(model_attr='start_date', faceted=True)
end_date = indexes.DateField(model_attr='end_date', faceted=True)
job_description = indexes.CharField(model_attr='job_description', faceted=True)
country = indexes.CharField(model_attr='country', faceted=True)
suggestions = indexes.FacetCharField()
def prepare(self, obj):
prepared_data = super(JobIndex, self).prepare(obj)
prepared_data['suggestions'] = prepared_data['text']
return prepared_data
def get_model(self):
return jobpost
def index_queryset(self,**kwargs):
return self.get_model().objects.all()
次に、solr_schema を作成して index..looked solrconfig.xml を適切な変更に置き換えました。ジャンゴシェルでテスト済み
>>> from haystack.query import SearchQuerySet
>>> sqs = SearchQuerySet().auto_query('spider')
>>> suggestion = sqs.spelling_suggestion()
>>> print suggestion
>>> None
わかりましたNone
、誰か助けてくれませんか?