0

我对 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(r'^search/', include('haystack.urls')),

查看代码

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

请告知我在哪里做错了

4

1 回答 1

0

感谢你的提问!面对同样的错误后,我终于找到了问题所在。对我来说,这是 haystack 无法处理的 solr 版本。我 按照以下步骤 安装了https://archive.apache.org/dist/lucene/solr/3.5.0/apache-solr-3.5.0.tgz:http://django-haystack.readthedocs.org/en/ latest/installing_search_engines.html#solr 和你一样的conf。希望这对你有用。干杯,马克斯

于 2014-03-18T20:12:53.887 回答