elasticsearch - elasticsearch不能rebuild_index

标签 elasticsearch django-haystack

我想使用干草堆+ elasticsearch

所以我安装了elasticsearch

$ brew info elasticsearch

elasticsearch: stable 5.0.1, HEAD
Distributed search & analytics engine
https://www.elastic.co/products/elasticsearch
/usr/local/Cellar/elasticsearch/5.0.1 (98 files, 34.8M) *
  Built from source on 2016-11-29 at 17:52:15
From: https://github.com/Homebrew/homebrew-core/blob/master/Formula/elasticsearch.rb
==> Requirements
Required: java >= 1.8 ✔
==> Caveats
Data:    /usr/local/var/elasticsearch/elasticsearch_hanminsoo/
Logs:    /usr/local/var/log/elasticsearch/elasticsearch_hanminsoo.log
Plugins: /usr/local/Cellar/elasticsearch/5.0.1/libexec/plugins/
Config:  /usr/local/etc/elasticsearch/
plugin script: /usr/local/Cellar/elasticsearch/5.0.1/libexec/bin/plugin

To have launchd start elasticsearch now and restart at login:
  brew services start elasticsearch
Or, if you don't want/need a background service you can just run:
  elasticsearch

然后我开始elasticsearch
$ brew services start elasticsearch

==> Tapping homebrew/services
Cloning into '/usr/local/Homebrew/Library/Taps/homebrew/homebrew-services'...
remote: Counting objects: 10, done.
remote: Compressing objects: 100% (7/7), done.
remote: Total 10 (delta 0), reused 6 (delta 0), pack-reused 0
Unpacking objects: 100% (10/10), done.
Checking connectivity... done.
Tapped 0 formulae (36 files, 47K)
==> Successfully started `elasticsearch` (label: homebrew.mxcl.elasticsearch)

我想重新索引
$ python manage.py rebuild_index

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.
DELETE http://127.0.0.1:9200/haystack [status:N/A request:0.002s

[...]

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/hanminsoo/.pyenv/versions/spec/lib/python3.5/site-packages/haystack/backends/elasticsearch_backend.py", line 231, in clear
self.conn.indices.delete(index=self.index_name, ignore=404)
  File "/Users/hanminsoo/.pyenv/versions/spec/lib/python3.5/site-packages/elasticsearch/client/utils.py", line 69, in _wrapped
return func(*args, params=params, **kwargs)
  File "/Users/hanminsoo/.pyenv/versions/spec/lib/python3.5/site-packages/elasticsearch/client/indices.py", line 198, in delete
params=params)
  File "/Users/hanminsoo/.pyenv/versions/spec/lib/python3.5/site-packages/elasticsearch/transport.py", line 307, in perform_request
status, headers, data = connection.perform_request(method, url, params, body, ignore=ignore, timeout=timeout)
  File "/Users/hanminsoo/.pyenv/versions/spec/lib/python3.5/site-packages/elasticsearch/connection/http_urllib3.py", line 89, in perform_request
raise ConnectionError('N/A', str(e), e)
elasticsearch.exceptions.ConnectionError: ConnectionError(<urllib3.connection.HTTPConnection object at 0x110791e48>: Failed to establish a new connection: [Errno 61] Connection refused) caused by: NewConnectionError(<urllib3.connection.HTTPConnection object at 0x110791e48>: Failed to establish a new connection: [Errno 61] Connection refused)
All documents removed.
 Indexing 0 products

产品未编制索引...

首先,我认为这是连接错误,
$ curl -v -X GET 127.0.0.1:9200

* Rebuilt URL to: 127.0.0.1:9200/
*   Trying 127.0.0.1...
* connect to 127.0.0.1 port 9200 failed: Connection refused
* Failed to connect to 127.0.0.1 port 9200: Connection refused
* Closing connection 0
curl: (7) Failed to connect to 127.0.0.1 port 9200: Connection refused

但是我设置settings.py
# Django Haystack
HAYSTACK_CONNECTIONS = {
    'default': {
    'ENGINE':'haystack.backends.elasticsearch_backend.ElasticsearchSearchEngine',
    'URL': 'http://127.0.0.1:9200/',
    'INDEX_NAME': 'haystack',
    'TIMEOUT': 10
    },
}

我尝试elasticsearch重新启动,然后重新安装pip,否则...

但我不明白为什么。

点冻结
appnope==0.1.0
certifi==2016.9.26
decorator==4.0.10
Django==1.9.7
django-debug-toolbar==1.5
django-extensions==1.7.2
django-haystack==2.5.1
djangorestframework==3.4.4
elasticsearch==1.9.0
get==0.0.0
httpie==0.9.6
ipython==5.0.0
ipython-genutils==0.1.0
pep8==1.7.0
pexpect==4.2.0
pickleshare==0.7.3
post==0.0.0
prompt-toolkit==1.0.3
ptyprocess==0.5.1
public==0.0.0
pyelasticsearch==1.4
Pygments==2.1.3
query-string==0.0.0
requests==2.12.2
setupfiles==0.0.0
simplegeneric==0.8.1
simplejson==3.10.0
six==1.10.0
sqlparse==0.2.1
traitlets==4.2.2
urllib3==1.19.1
wcwidth==0.1.7

Java版本
java version "1.8.0_112"
Java(TM) SE Runtime Environment (build 1.8.0_112-b16)
Java HotSpot(TM) 64-Bit Server VM (build 25.112-b16, mixed mode)

最佳答案

这是因为您的ES服务器未启动。

根据您的日志,需要在discovery.zen.ping.timeout文件中将discovery.zen.ping_timeout更改为/usr/local/etc/elasticsearch/elasticsearch.yml并重新启动ES。

关于elasticsearch - elasticsearch不能rebuild_index,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40926062/

相关文章:

java - 在 ElasticSearch 中使用 Java API 搜索具有 Id 的字段时找不到文档

python - 使用 Django REST Framework 的 Solr 搜索结果

elasticsearch - Django Haystack 通过 Elasticsearch 后端按距离排序,而不是 geo_point 字段错误

elasticsearch - 模糊性不符合Elasticsearch的预期

elasticsearch - azure evenhub 插件和 Filebeat azure 模块的区别

regex - 无法识别的字符转义 '-' | Elasticsearch

elasticsearch - 如何更改记录分数

python - MapperParsingException 在使用 elasticsearch 在 django-haystack 中执行 rebuild_index

python - 所有 'SearchIndex' 类必须对 'text' 字段使用相同的 'document=True' 字段名。违规索引为 '<personal.search_indexes.PostIndex