簡體   English   中英

Ruby on Rails應用程序:ElasticSearch錯誤“類型” =>“ cluster_block_exception”

[英]Ruby on Rails App: ElasticSearch Error “type”=>“cluster_block_exception”

{"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

在這里嘗試此解決方案https://stackoverflow.com/a/50609418/3573300我遇到了類似情況,這是因為我的群集上沒有剩余空間了

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM