Django haystack拼写检查

Django haystack拼写检查,django,solr,spell-checking,django-haystack,Django,Solr,Spell Checking,Django Haystack,我的拼写检查一个也没有 首先,我在settings.py中进行了更改 HAYSTACK_CONNECTIONS = { 'default': { 'ENGINE': 'haystack.backends.solr_backend.SolrEngine', 'URL': 'http://127.0.0.1:8983/solr', 'INCLUDE_SPELLING': True, }, } 在search_index.py中进行了更

我的拼写检查一个也没有

首先,我在settings.py中进行了更改

HAYSTACK_CONNECTIONS = {
    'default': {
        'ENGINE': 'haystack.backends.solr_backend.SolrEngine',
        'URL': 'http://127.0.0.1:8983/solr',
        'INCLUDE_SPELLING': True,
    },
}
在search_index.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_模式替换它重建索引..查找solrconfig.xml以查找合适的技术。 通过django shell进行测试

>>> from haystack.query import SearchQuerySet
>>> sqs = SearchQuerySet().auto_query('spider')
>>> suggestion = sqs.spelling_suggestion()
>>> print suggestion
>>> None

获得
None
,有人能帮我吗?

要使用SearchQuerySet进行拼写检查,需要将拼写检查组件绑定到标准查询处理程序

这是通过将其添加到solrconfig.xml文件中的默认requestHandler来完成的:

 <arr name="last-components">
     <str>spellcheck</str>
     ...         
 </arr>

您应该使用以下命令重建索引:

python manage.py重建索引

发件人:

若要工作,必须将连接的设置词典中的INCLUDE_SPELLING设置为True,然后必须重新生成索引。否则,将不返回任何内容