使用 Whoosh 和 Django Haystack 时出现 ValueError

发布于 2024-10-01 15:19:40 字数 1415 浏览 6 评论 0原文

我正在尝试使用 Whoosh 设置 Haystack,但当我在 ./manage shell 中的 SearchQuerySet 对象上运行 count 方法时,出现此值错误“ValueError:字典更新序列元素 #0 的长度为 9;需要 2”

>>> sqs.count()
Traceback (most recent call last):
  File "<console>", line 1, in <module>
  File "/usr/local/lib/python2.6/dist-packages/haystack/query.py", line 375, in count
    return len(clone)
  File "/usr/local/lib/python2.6/dist-packages/haystack/query.py", line 48, in __len__
    self._result_count = self.query.get_count()
  File "/usr/local/lib/python2.6/dist-packages/haystack/backends/__init__.py", line 399, in get_count
    self.run()
  File "/usr/local/lib/python2.6/dist-packages/haystack/backends/__init__.py", line 354, in run
    results = self.backend.search(final_query, **kwargs)
  File "/usr/local/lib/python2.6/dist-packages/haystack/backends/__init__.py", line 47, in wrapper
    return func(obj, query_string, *args, **kwargs)
  File "/usr/local/lib/python2.6/dist-packages/haystack/backends/whoosh_backend.py", line 313, in search
    return self._process_results(raw_results, start_offset, end_offset, highlight=highlight, query_string=query_string, spelling_query=spelling_query)
  File "/usr/local/lib/python2.6/dist-packages/haystack/backends/whoosh_backend.py", line 350, in _process_results
    raw_result = dict(raw_result)
ValueError: dictionary update sequence element #0 has length 9; 2 is required

I'm trying to set up Haystack with Whoosh but am getting this value error "ValueError: dictionary update sequence element #0 has length 9; 2 is required" when I run the count method on the SearchQuerySet object in ./manage shell

>>> sqs.count()
Traceback (most recent call last):
  File "<console>", line 1, in <module>
  File "/usr/local/lib/python2.6/dist-packages/haystack/query.py", line 375, in count
    return len(clone)
  File "/usr/local/lib/python2.6/dist-packages/haystack/query.py", line 48, in __len__
    self._result_count = self.query.get_count()
  File "/usr/local/lib/python2.6/dist-packages/haystack/backends/__init__.py", line 399, in get_count
    self.run()
  File "/usr/local/lib/python2.6/dist-packages/haystack/backends/__init__.py", line 354, in run
    results = self.backend.search(final_query, **kwargs)
  File "/usr/local/lib/python2.6/dist-packages/haystack/backends/__init__.py", line 47, in wrapper
    return func(obj, query_string, *args, **kwargs)
  File "/usr/local/lib/python2.6/dist-packages/haystack/backends/whoosh_backend.py", line 313, in search
    return self._process_results(raw_results, start_offset, end_offset, highlight=highlight, query_string=query_string, spelling_query=spelling_query)
  File "/usr/local/lib/python2.6/dist-packages/haystack/backends/whoosh_backend.py", line 350, in _process_results
    raw_result = dict(raw_result)
ValueError: dictionary update sequence element #0 has length 9; 2 is required

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

Oo萌小芽oO 2024-10-08 15:19:40

在这里找到我的答案 https://github.com/toastdriven/django-haystack /issues/close#issue/281 原来是版本问题。

如果我使用 Haystack 和 Whoosh 的这些特定版本,它就会起作用

pip install django-haystack==1.0.1-final

easy_install "Whoosh==1.0.0.b11"

Found my answer here https://github.com/toastdriven/django-haystack/issues/closed#issue/281 It turns out it was a version problem.

It works if I use these specific versions of Haystack and Whoosh

pip install django-haystack==1.0.1-final

easy_install "Whoosh==1.0.0.b11"
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文