Rails 上的 Ruby - searchkick gem : cluster_block_exception - FORBIDDEN/12/index 只读/允许删除 (api) - 状态":403
Ruby on Rails - searchkick gem : cluster_block_exception - FORBIDDEN/12/index read-only / allow delete (api) - status":403
我正在尝试使用 searchkick gem
将 elasticsearch
添加到我在 Rails 网站上的 Ruby。我目前使用的 OS 是 Ubuntu 16.04 TLS。
我安装了 elasticsearch 6.2.2,到目前为止,默认配置没有改变。
当我 运行 curl -X GET 'http://localhost:9200'
我得到:
{
"name" : "viTKcuN",
"cluster_name" : "elasticsearch",
"cluster_uuid" : "aHCpbpvoQd2sieJRWtqI7g",
"version" : {
"number" : "6.2.2",
"build_hash" : "10b1edd",
"build_date" : "2018-02-16T19:01:30.685723Z",
"build_snapshot" : false,
"lucene_version" : "7.2.1",
"minimum_wire_compatibility_version" : "5.6.0",
"minimum_index_compatibility_version" : "5.0.0"
},
"tagline" : "You Know, for Search"
}
我猜这就是所需的输出。
然后我将 gem 'searchkick', '~> 3.0'
添加到我的 Gemfile,运行 bundle install
并将 searchkick
添加到我的模型。
然而,运行ning Activity.reindex
在终端中导致:
Activity.reindex: command not found
运行 rake searchkick:reindex CLASS=Activity
导致了愚蠢的错误:
rails searchkick earchkick::ImportError: {"type"=>"cluster_block_exception", "reason"=>"blocked by: [FORBIDDEN/12/index read-only / allow delete (api)];"} on item with id '1'
我试过了运行宁curl -XPUT -H "Content-Type: application/json" http://localhost:9200/_all/_settings -d '{"index.blocks.read_only_allow_delete": null}'
但随后重新运行宁 rake searchkick:reindex CLASS=Activity
再次导致以下结果:
Elasticsearch::Transport::Transport::Errors::Forbidden: [403] {"error":{"root_cause":[{"type":"cluster_block_exception","reason":"blocked by: [FORBIDDEN/12/index read-only / allow delete (api)];"}],"type":"cluster_block_exception","reason":"blocked by: [FORBIDDEN/12/index read-only / allow delete (api)];"},"status":403}
我也尝试将 searchkick settings: {blocks: {read_only: false}}
添加到 Activity 模型,但是当我再次 运行 rake searchkick:reindex CLASS=Activity
时出现了同样的错误。
我该如何解决这个问题。
我在控制台中通过 运行 Activity.search_index.delete
修复了它,然后重新运行 Activity.reindex
当我得到这个 运行 rspec 测试时,以下对我有用,并且设置测试数据库环境的第一个 dB 插入因这个弹性搜索错误而失败。修复摘自here,重点观察:
By default, Elasticsearch installed with homebrew on Mac OS goes into read-only mode when you have less than 5% of free disk space.
curl -XPUT -H "Content-Type: application/json" http://localhost:9200/_cluster/settings -d '{ "transient": { "cluster.routing.allocation.disk.threshold_enabled": false } }'
curl -XPUT -H "Content-Type: application/json" http://localhost:9200/_all/_settings -d '{"index.blocks.read_only_allow_delete": null}'
我正在尝试使用 searchkick gem
将 elasticsearch
添加到我在 Rails 网站上的 Ruby。我目前使用的 OS 是 Ubuntu 16.04 TLS。
我安装了 elasticsearch 6.2.2,到目前为止,默认配置没有改变。
当我 运行 curl -X GET 'http://localhost:9200'
我得到:
{
"name" : "viTKcuN",
"cluster_name" : "elasticsearch",
"cluster_uuid" : "aHCpbpvoQd2sieJRWtqI7g",
"version" : {
"number" : "6.2.2",
"build_hash" : "10b1edd",
"build_date" : "2018-02-16T19:01:30.685723Z",
"build_snapshot" : false,
"lucene_version" : "7.2.1",
"minimum_wire_compatibility_version" : "5.6.0",
"minimum_index_compatibility_version" : "5.0.0"
},
"tagline" : "You Know, for Search"
}
我猜这就是所需的输出。
然后我将 gem 'searchkick', '~> 3.0'
添加到我的 Gemfile,运行 bundle install
并将 searchkick
添加到我的模型。
然而,运行ning Activity.reindex
在终端中导致:
Activity.reindex: command not found
运行 rake searchkick:reindex CLASS=Activity
导致了愚蠢的错误:
rails searchkick earchkick::ImportError: {"type"=>"cluster_block_exception", "reason"=>"blocked by: [FORBIDDEN/12/index read-only / allow delete (api)];"} on item with id '1'
我试过了运行宁curl -XPUT -H "Content-Type: application/json" http://localhost:9200/_all/_settings -d '{"index.blocks.read_only_allow_delete": null}'
但随后重新运行宁 rake searchkick:reindex CLASS=Activity
再次导致以下结果:
Elasticsearch::Transport::Transport::Errors::Forbidden: [403] {"error":{"root_cause":[{"type":"cluster_block_exception","reason":"blocked by: [FORBIDDEN/12/index read-only / allow delete (api)];"}],"type":"cluster_block_exception","reason":"blocked by: [FORBIDDEN/12/index read-only / allow delete (api)];"},"status":403}
我也尝试将 searchkick settings: {blocks: {read_only: false}}
添加到 Activity 模型,但是当我再次 运行 rake searchkick:reindex CLASS=Activity
时出现了同样的错误。
我该如何解决这个问题。
我在控制台中通过 运行 Activity.search_index.delete
修复了它,然后重新运行 Activity.reindex
当我得到这个 运行 rspec 测试时,以下对我有用,并且设置测试数据库环境的第一个 dB 插入因这个弹性搜索错误而失败。修复摘自here,重点观察:
By default, Elasticsearch installed with homebrew on Mac OS goes into read-only mode when you have less than 5% of free disk space.
curl -XPUT -H "Content-Type: application/json" http://localhost:9200/_cluster/settings -d '{ "transient": { "cluster.routing.allocation.disk.threshold_enabled": false } }'
curl -XPUT -H "Content-Type: application/json" http://localhost:9200/_all/_settings -d '{"index.blocks.read_only_allow_delete": null}'