haystack为每个搜索请求花费很长时间

时间:2014-04-08 00:45:11

标签: python django django-haystack whoosh

我对干草堆地区有问题,希望你们中的一些人能给我一些建议

在我的应用程序中,每次搜索请求需要很长时间,而haystack的CPU成本很高。这是一些日志:

Building Trie..., from /Users/yonzhang/script/hss/hibox/demo/jieba/dict.txt

loading model from cache /var/folders/2y/nmm0yhhx3tx0mwjrt8yqztxr0000gn/T/jieba.cache

loading model cost 1.41886401176 seconds.

Trie has been built succesfully.

有时候我会遇到这样的错误日志:

Traceback (most recent call last):
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/wsgiref/handlers.py", line 86, in run
    self.finish_response()
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/wsgiref/handlers.py", line 128, in finish_response
    self.write(data)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/wsgiref/handlers.py", line 212, in write
    self.send_headers()
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/wsgiref/handlers.py", line 270, in send_headers
    self.send_preamble()
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/wsgiref/handlers.py", line 194, in send_preamble
    'Date: %s\r\n' % format_date_time(time.time())
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/socket.py", line 324, in write
    self.flush()
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/socket.py", line 303, in flush
    self._sock.sendall(view[write_offset:write_offset+buffer_size])
error: [Errno 32] Broken pipe
[08/Apr/2014 08:35:36] "GET /search?q=%E4%BA%A7%E5%93%81%E7%BB%8F%E7%90%86 HTTP/1.1" 500 59

感谢建议〜

yonzhang

1 个答案:

答案 0 :(得分:0)

似乎您为一个请求剪切了每个查询,并且每次都加载dict。

您可以考虑将word-cut作为服务。