3
使用https://gist.github.com/wingdspur/2026107其在http://localhost:9200
开始的elasticsearch集群在我的机器上安装elasticsearch后,我试图创建与设置的指标,用这个代码:IndexPrimaryShardNotAllocatedException错误,而试图关闭一个elasticsearch集群
search_indices.create index: 'test'
search_indices.refresh index: 'test'
search_indices.close index: 'test'
search_indices.put_settings(index: 'test', **my_index_settings)
search_indices.put_mapping(index: 'test', **my_mapping_settings)
search_indices.open index: 'test'
在哪里
search_indices = Elasticsearch::Client.new({host: 'http://localhost:9200'}).indices
# this module comes from the elasticsearch-ruby gem
当我执行此代码,我得到一个错误时,我试图执行“关闭”方法(上述第3行)
Elasticsearch::Transport::Transport::Errors::Conflict:
[409] {"error":"IndexPrimaryShardNotAllocatedException[[test_1] primary not allocated post api]","status":409}
我尝试添加刷新方法(上面的第2行)有时工作,有时没有,我有'有时工作'的感觉意味着我做错了什么。谢谢您的帮助!
正如仅供参考,您不需要关闭索引来更改设置/映射。打开/关闭实际上仅用于归档您想要保留的旧数据,但不需要主动搜索。 – Zach
@ Zach,除非您在put设置调用中注册新的分析仪,在这种情况下,您确实需要关闭并重新打开索引。 http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/indices-update-settings.html –
@MartijnLaarman啊,很好,谢谢澄清! – Zach