【问题标题】:Ruby on Rails App: ElasticSearch Error "type"=>"cluster_block_exception"Ruby on Rails 应用程序:ElasticSearch 错误“type”=>“cluster_block_exception”
【发布时间】:2019-03-08 13:26:47
【问题描述】:
{"type"=>"cluster_block_exception", "reason"=>"blocked by: [FORBIDDEN/12/index read-only / allow delete (api)];"} on item with id '2'

这是我遇到的错误。 我做了什么:

rails db:drop db:create db:migrate
rails c and Model.reindex (failed)

错误:

  [1] pry(main)> Post.reindex
  Post Load (0.4ms)  SELECT  "posts".* FROM "posts" ORDER BY "posts"."id" ASC 
  LIMIT $1  [["LIMIT", 1000]]
  Post Import (137.9ms)  {"count":1,"id":1}
  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}
  from 
  /Users/CHAFET/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/elasticsearch- 
  transport-6.1.0/lib/elasticsearch/transport/transport/base.rb:205:in 
  `__raise_transport_error'

然后我再次进入我的 Rails 控制台并运行“Post.search_index.delete”

  Post Import (99.1ms)  {"count":1,"id":1}
  => true

然后我尝试再次进入我的模型“显示”或“保存”,它在此叙述之上引发了错误:

{"type"=>"cluster_block_exception", "reason"=>"blocked by: [FORBIDDEN/12/index 
read-only / allow delete (api)];"} on item with id '2'
  • 当我按“创建帖子”时,它给了我一个错误
  • 请注意,如果我按“返回”,则会创建“帖子”

这是我的 Post 控制器:

class PostsController < ApplicationController
    before_action :set_post, only: [ :edit, :update, :destroy, :show]
    skip_before_action :authenticate_user!

    def index
      if params[:query]
        @posts = Post.search(params[:query])
      else
        @posts = Post.all
      end
        @top_post = Post.order(view: :desc).first
        @popular_posts = Post.order(view: :desc).first(4) - [@top_post]
    end

    def new
      @post = Post.new
    end

    def create
      @post = Post.new(post_params)
      @post.view = 0
      @post.user = current_user
      if @post.save
        redirect_to dashboard_path
      else
        render :new
      end
    end

    def show
        @popular_posts = Post.order(view: :desc).first(4) - [@top_post]
        @post.view += 1
        @post.save
    end

    def dashboard
        @posts = Post.all
    end

    def edit
    end

    def update
      @post.update(post_params)
      redirect_to post_path
   end

    def destroy
      @post.destroy
      redirect_to dashboard_path
    end

    private

    def set_post
      @post = Post.find(params[:id])
    end

    def post_params
      params.require(:post).permit(:title, :content, :photo)
    end
end

【问题讨论】:

    标签: ruby-on-rails elasticsearch


    【解决方案1】:

    在这里尝试这个解决方案https://stackoverflow.com/a/50609418/3573300 我遇到了类似的情况,这是因为我的集群上没有更多空间了

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2016-12-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多