拼寫建議獲取「無」。拼寫建議顯示「無」乾草堆
settings.py包含 'INCLUDE_SPELLING':真
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.CharField()
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
rebuilded指數多次。
solrconfig.xml中
<searchComponent name="spellcheck" class="solr.SpellCheckComponent">
<str name="queryAnalyzerFieldType">textSpell</str>
<lst name="spellchecker">
<str name="name">default</str>
<str name="field">suggestions</str>
<str name="spellcheckIndexDir">./spellchecker1</str>
<str name="buildOnCommit">true</str>
</lst>
<requestHandler name="/spell" class="solr.SearchHandler" startup="lazy">
<lst name="defaults">
<str name="df">text</str>
<str name="spellcheck.onlyMorePopular">false</str>
<str name="spellcheck.extendedResults">false</str>
<str name="spellcheck.count">1</str>
</lst>
<arr name="last-components">
<str>spellcheck</str>
</arr>
</requestHandler>
schema.xml中包含的建議現場
<field name="suggestions" type="text_en" indexed="true" stored="true" multiValued="true" termVectors="true" termPositions="true" termOffsets="true" />
誰能告訴它爲什麼顯示 '無'?
您正在使用哪種haystack版本? –
haystack 2.0.1 .. –