haystack.exceptions.SearchBackendError:在任何search_indexes中找不到任何字段。尝试搜索之前请更正 [英] haystack.exceptions.SearchBackendError: No fields were found in any search_indexes. Please correct this before attempting to search
问题描述
我一直在收到这个错误,尽管一切似乎都被配置好了。我收到错误:
haystack.exceptions.SearchBackendError:在任何search_indexes中找不到字段。尝试搜索之前请更正。
...当我尝试执行 ./ manage.py rebuild_index
配置:
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 *
$ b $来自haystack.indexes import的$
从haystack导入站点
来自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
text = CharField(document = True,use_template = True)
abstract = TextField(model_attr ='abstract')
methods = TextField(model_attr ='methods')
year = IntegerField(model_attr ='year')
name = CharField(model_attr ='name')
class Graph(SearchIndex):
text = CharField(document = True,use_template = True)
explain = TextField(model_attr ='explain')
type = CharField(model_attr ='type ')
name = CharField(model_attr ='name')
site.register(研究人员,研究员指数)
site.register(Subject,SubjectIndex)
网站。注册(Research,ResearchIndex)
site.register(Graph,GraphIndex)
谢谢
问题出在你的 HAYSTACK_SITECONF
中。它必须是您的 search_sites
文件的路径。修正这个,它应该可以工作。
I am trying to implement Haystack with whoosh.
I keep getting this error although everything seems to be configured fine. I get the error:
haystack.exceptions.SearchBackendError: No fields were found in any search_indexes. Please correct this before attempting to search.
...when I try to do ./manage.py rebuild_index
configuration:
HAYSTACK_SITECONF = 'myproject'
HAYSTACK_SEARCH_ENGINE = 'whoosh'
HAYSTACK_WHOOSH_PATH = cwd + '/whoosh/mysite_index'
There are successfully created whoosh/mysite_index directories in the root folder of my project.
*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)
Thanks
the problem is in your HAYSTACK_SITECONF
. It must be the path to your search_sites
file. Fix this and it should work.
这篇关于haystack.exceptions.SearchBackendError:在任何search_indexes中找不到任何字段。尝试搜索之前请更正的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!