Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/solr/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用django haystack进行搜索时遇到错误-未定义字段django_ct_Django_Solr_Django Haystack - Fatal编程技术网

使用django haystack进行搜索时遇到错误-未定义字段django_ct

使用django haystack进行搜索时遇到错误-未定义字段django_ct,django,solr,django-haystack,Django,Solr,Django Haystack,我对django haystack是一个全新的人,我在开始使用它的时候遇到了麻烦 当我搜索时,我得到一个错误 Failed to query Solr using '*:*': [Reason: Error 400 undefined field django_ct] 当我重建索引时,我得到了这个错误 WARNING: This will irreparably remove EVERYTHING from your search index in connection 'default'.

我对django haystack是一个全新的人,我在开始使用它的时候遇到了麻烦

当我搜索时,我得到一个错误

Failed to query Solr using '*:*': [Reason: Error 400 undefined field django_ct]
当我重建索引时,我得到了这个错误

WARNING: This will irreparably remove EVERYTHING from your search index in connection 'default'. Your choices after this are to restore from backups or rebuild via the `rebuild_index` command.
Are you sure you wish to continue? [y/N] y
Removing all documents from your index because you said so.
All documents removed.
ERROR:root:Error updating votingapp using default
Traceback (most recent call last):
...
...
index_qs = self.index_queryset(using=using)
TypeError: index_queryset() got an unexpected keyword argument 'using'
我已经建立了一个简单的索引类

class QuestionsIndex(indexes.SearchIndex, indexes.Indexable):
    text = indexes.CharField(document=True, use_template=True)
    qs = indexes.CharField(model_attr='question')

    def get_model(self):
        return Questions

    def index_queryset(self):
        return self.get_model().objects.all()
在settings.py中添加了代码

HAYSTACK_CONNECTIONS = {
    'default': {
        'ENGINE': 'haystack.backends.solr_backend.SolrEngine',
        'URL': 'http://127.0.0.1:8983/solr'
        # ...or for multicore...
        # 'URL': 'http://127.0.0.1:8983/solr/mysite',
    },
}
添加了url

url(r'^search/', include('haystack.urls')),
视图代码

def home(request):
    if request.method == "POST":
        print SearchQuerySet().all()
    return render_to_response('search.html',{})

请告知我哪里做错了

谢谢你的提问! 面对同样的错误,我终于找到了问题所在。对我来说,这是haystack无法处理的solr版本。 我安装了 循序渐进: 和你一样的姿势。 希望这对你有用。 干杯
Max

您没有使用
index\u queryset()
的关键字参数添加
。如果您想要该关键字,它应该是
index\u queryset(self,using=None)
。嘿,谢谢,现在我在重建-->时遇到此错误-->无法向Solr添加文档:[原因:错误400错误:[doc=votingapp.questions.1]未知字段'django\u ct']。您能告诉我理解haystack工作的好参考资料吗您的
schema.xml
是否有
django\u ct
字段?好的文档是实际的文档->我没有在solr中构建schema.xml,我以为haystack会用search_index.py构建它。不,如果你没有这样做,你必须运行management命令
manage.py build\u solr\u schema