2013-04-20 57 views
6

即時通訊使用django乾草堆elasticsearch但存在索引問題。當重建我的指數上升Django乾草堆與彈性搜索,索引問題

 python manage.py rebuild_index
以下錯誤:

 
Traceback (most recent call last): 
    File "/home/palo/.virtualenvs/toro/local/lib/python2.7/site-packages/haystack/management/commands/update_index.py", line 210, in handle_label 
    self.update_backend(label, using) 
    File "/home/palo/.virtualenvs/toro/local/lib/python2.7/site-packages/haystack/management/commands/update_index.py", line 256, in update_backend 
    do_update(backend, index, qs, start, end, total, self.verbosity) 
    File "/home/palo/.virtualenvs/toro/local/lib/python2.7/site-packages/haystack/management/commands/update_index.py", line 78, in do_update 
    backend.update(index, current_qs) 
    File "/home/palo/.virtualenvs/toro/local/lib/python2.7/site-packages/haystack/backends/elasticsearch_backend.py", line 177, in update 
    self.conn.bulk_index(self.index_name, 'modelresult', prepped_docs, id_field=ID) 
    File "/home/palo/.virtualenvs/toro/src/pyelasticsearch/pyelasticsearch/client.py", line 95, in decorate 
    return func(*args, query_params=query_params, **kwargs) 
    File "/home/palo/.virtualenvs/toro/src/pyelasticsearch/pyelasticsearch/client.py", line 366, in bulk_index 
    query_params=query_params) 
    File "/home/palo/.virtualenvs/toro/src/pyelasticsearch/pyelasticsearch/client.py", line 221, in send_request 
    **({'data': request_body} if body else {})) 
    File "/home/palo/.virtualenvs/toro/src/requests/requests/sessions.py", line 387, in post 
    return self.request('POST', url, data=data, **kwargs) 
    File "/home/palo/.virtualenvs/toro/src/requests/requests/sessions.py", line 345, in request 
    resp = self.send(prep, **send_kwargs) 
    File "/home/palo/.virtualenvs/toro/src/requests/requests/sessions.py", line 448, in send 
    r = adapter.send(request, **kwargs) 
    File "/home/palo/.virtualenvs/toro/src/requests/requests/adapters.py", line 324, in send 
    raise Timeout(e) 
Timeout: HTTPConnectionPool(host='127.0.0.1', port=9200): Request timed out. (timeout=10) 
Timeout: HTTPConnectionPool(host='127.0.0.1', port=9200): Request timed out. (timeout=10) 

我用Django的草垛 - 2.0.0-β,pyelasticsearch - 0.5,elasticsearch 0.20.6,Java版本 「1.6.0_24」


草堆設置

 

    HAYSTACK_CONNECTIONS = { 
     'default': { 
      'ENGINE': 'haystack.backends.elasticsearch_backend.ElasticsearchSearchEngine', 
      'URL': 'http://127.0.0.1:9200/', 
      'INDEX_NAME': 'haystack', 
     }, 
    } 

而且我敢肯定,我的elasticsearch serivce運行。

+0

這聽起來像你ElasticSearch實例不可用。 「curl -XGET'localhost:9200'」的結果是什麼?您應該看到帶有服務器狀態和版本的JSON輸出。 – bennylope 2013-04-21 03:25:37

+0

這是否解決了這個問題 – 2013-06-26 18:34:36

回答

13

這並不一定意味着你的es服務器關閉了,特別是如果你得到合理的返回curl -I "127.0.0.1:9200"。更可能的是,由於涉及到連接的速度,這是您的請求的問題,根本沒有足夠的時間。

有趣的是,在pyelasticsearch中設置的默認超時時間爲60秒,請參閱def __init__(self, urls, timeout=60, max_retries=0, revival_delay=300):,https://github.com/rhec/pyelasticsearch/blob/master/pyelasticsearch/client.py。然而,乾草堆會用self.timeout = connection_options.get('TIMEOUT', 10)https://github.com/toastdriven/django-haystack/blob/master/haystack/backends/__init__.py中的默認設置(即10秒)來覆蓋它。

正如你所看到的,乾草堆允許你輕鬆地修改你的設置,在你的引擎配置中加入'TIMEOUT': 60,

,解決了:)

-2

你運行

bin/elasticsearch -f 

我想你沒有運行的搜索引擎。

1

我也曾經有過類似的問題

sudo的服務elasticsearch重啓

那麼它的工作

+0

這解決了我的服務器磁盤空間不足後的問題。 – creimers 2016-08-17 08:54:20