[英]Elasticsearch::Transport::Transport::Errors::NotFound: [404]
[英]Activeadmin Destroy Record with Exception Elasticsearch::Transport::Transport::Errors::NotFound in Admin [404]
我已經在Rails應用程序API中配置了Elasticsearch,對於Post模型,它可以正常工作,並且我正在使用@post.destroy!
刪除特定記錄沒有任何問題,但是當我通過Activeadmin面板中的destroy動作(我嘗試使用默認的destroy動作和自定義控制器-> destroy action)嘗試相同操作時, 這里發生的是從db中正確刪除記錄,但是刪除后它拋出一個異常 :
Elasticsearch::Transport::Transport::Errors::NotFound in Admin::PostsController#destroy
[404] {"found":false,"_index":"posts","_type":"post","_id":"1802","_version":1,"_shards":{"total":2,"successful":1,"failed":0}}
我已經嘗試了Elasticsearch-model文檔中提到的所有自定義回調,但是我發現的唯一解決方案是使用begin .. rescue
語句:
@deleted = false
begin
@post.destroy!
rescue
Post.find_by(:id => id).present? ? @deleted = false : @deleted = true
#delete successful action here if @deleted == true
end
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.