I am getting None in spell check
first i made changes in settings.py
HAYSTACK_CONNECTIONS = {
'default': {
'ENGINE': 'haystack.backends.solr_backend.SolrEngine',
'URL': 'http://127.0.0.1:8983/solr',
'INCLUDE_SPELLING': True,
},
}
made changes in 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()
Then made solr_schema replaced it rebuild index..looked solrconfig.xml for appropriate chnages. Tested through django shell
>>> from haystack.query import SearchQuerySet
>>> sqs = SearchQuerySet().auto_query('spider')
>>> suggestion = sqs.spelling_suggestion()
>>> print suggestion
>>> None
Got None, can anyone help me?
You should rebuild your indexes using this command:
python manage.py rebuild_index
From the docs:
To work, you must set INCLUDE_SPELLING within your connection’s settings dictionary to True, and you must rebuild your index afterwards. Otherwise, None will be returned.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With