gpt4 book ai didi

django - haystack.exceptions.SearchBackendError : No fields were found in any search_indexes. 请在尝试搜索之前更正此问题

转载 作者:行者123 更新时间:2023-12-04 21:45:21 28 4
gpt4 key购买 nike

我正在尝试用 whoosh 实现 Haystack。

尽管一切似乎都配置得很好,但我不断收到此错误。我收到错误:

haystack.exceptions.SearchBackendError: No fields were found in any search_indexes. Please correct this before attempting to search.

...当我尝试做 ./manage.py 重建索引

配置:
HAYSTACK_SITECONF = 'myproject'
HAYSTACK_SEARCH_ENGINE = 'whoosh'
HAYSTACK_WHOOSH_PATH = cwd + '/whoosh/mysite_index'

有成功创建 whoosh/mysite_index 我的项目根文件夹中的目录。

*search_sites.py*
import haystack
haystack.autodiscover()

*search_indexes.py*
from haystack.indexes import *
from haystack import site
from myproject.models import *

class ResearchersIndex(SearchIndex):
text = CharField(document=True, use_template=True)
name = CharFIeld(model_attr='name')

class SubjectIndex(SearchIndex):
short_name = CharField(model_attr='short_name')
name = CharField(model_attr='name')
text = CharField(document=True, use_template=True)

class ResearchIndex(SearchIndex):
text = CharField(document=True, use_template=True)
abstract = TextField(model_attr='abstract')
methodology = TextField(model_attr='methodology')
year = IntegerField(model_attr='year')
name = CharField(model_attr='name')


class Graph(SearchIndex):
text = CharField(document=True, use_template=True)
explanation = TextField(model_attr='explanation')
type = CharField(model_attr='type')
name = CharField(model_attr='name')

site.register(Researchers, ResearchersIndex)
site.register(Subject, SubjectIndex)
site.register(Research, ResearchIndex)
site.register(Graph, GraphIndex)

谢谢

最佳答案

问题出在您的 HAYSTACK_SITECONF .它必须是您的 search_sites 的路径文件。解决这个问题,它应该可以工作。

关于django - haystack.exceptions.SearchBackendError : No fields were found in any search_indexes. 请在尝试搜索之前更正此问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15270347/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com