我已经配置Django干草堆与Elasticsearch搜索引擎使用QueuedSignalProcessor
与redis
队列后端。一切工作,除了现在我有一些问题。我有两个对象在db中,它的标题是code fixes
和code fixess
(最后有额外的s
)。我需要执行部分搜索。当我搜索code fix
它返回对象与标题code fixes
,但它不与标题code fixess
返回对象:django干草堆没有按照期望返回结果
my_model = SearchQuerySet().models(MyModel)
objects = my_model.filter(content__contains=q) # q = "code fix"
索引文件:
from haystack import indexes
from myapp.models import MyModel
class MyModelIndex(indexes.SearchIndex, indexes.Indexable):
text = indexes.CharField(document=True, use_template=True)
title = indexes.CharField(model_attr="title")
指数模板:
{{ object.title }}
{{ object.description }}
PS索引被更新。就好像我搜索fixess
它显示标题为code fixess
的第二个对象,但在这种情况下不是第一个。如果我只搜索code
,它会返回两者。
会是什么原因?