问题描述
我正在尝试在 django 中使用 haystack 和 elasticsearch 在我的网站上使用搜索引擎。 引擎将能够在我的 sql 数据库中搜索,包含文本和文件(pdf 或其他),但一开始,我只想搜索文本字段
我刚刚学习了本教程:tutorial django haystack
但我收到以下错误:
from haystack import indexes
from .models import Other
class OtherIndex(indexes.SearchIndex,indexes.Indexable):
text = indexes.CharField(document=True,use_template=True)
title = indexes.CharField(model_attr='title')
description = indexes.CharField(model_attr='description')
def get_model(self):
return Other
def index_queryset(self,using=None):
return self.get_model().objects.all()
我不知道如何更改“include_type_name”参数。
我刚刚更改了“search_indexes.py”以适应我的模型“其他”:
这是我的 search_indexes.py :
description = models.TextField()
title = models.CharField(max_length=255)
我的其他 models.py 包含 2 个字段:
{{1}}
我只是选择了这 2 个字段进行测试,但我的 Other models.py 有很多其他字段
否则,我遵循教程的每个步骤。
谢谢。
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)