【问题标题】:Elasticsearch & Bonsai: IndexMissingException on Heroku, works fine locallyElasticsearch 和 Bonsai:Heroku 上的 IndexMissingException,在本地运行良好
【发布时间】:2015-07-29 22:47:19
【问题描述】:

构建我的第一个 Rails 应用程序,但在让 Elasticsearch 在 Heroku 上运行时遇到问题。

本地作品完美。

在 Heroku 上我可以打开搜索页面,但是当我尝试执行搜索时出现以下错误:

Heroku 日志显示:

2015-05-18T12:05:15.969673+00:00 app[web.1]: ActionView::Template::Error ([404] {"error":"IndexMissingException[[homes] missing]","status":404}):
2015-05-18T12:05:15.969674+00:00 app[web.1]:      9: <% end %>
2015-05-18T12:05:15.969676+00:00 app[web.1]:     10:  
2015-05-18T12:05:15.969677+00:00 app[web.1]:     11: <ul>
2015-05-18T12:05:15.969678+00:00 app[web.1]:     12:   <% @homes.each do |home| %>
2015-05-18T12:05:15.969679+00:00 app[web.1]:     13:     <li>
2015-05-18T12:05:15.969680+00:00 app[web.1]:     14:       <h3>
2015-05-18T12:05:15.969682+00:00 app[web.1]:     15:         <%= link_to home.name, controller: "homes", action: "show", id: home._id%>
2015-05-18T12:05:15.969683+00:00 app[web.1]:   app/views/search/search.html.erb:12:in `_app_views_search_search_html_erb___1261310385184340853_69929402195100'

宝石:

gem 'elasticsearch-model'
gem 'elasticsearch-rails'
gem 'bonsai-elasticsearch-rails', '~> 0.0.4'

搜索控制器:

class SearchController < ApplicationController
    def search
      if params[:q].nil?
        @homes = []
      else
        @homes = Home.search params[:q]
      end
    end 
end

搜索视图:

<h1>Homes Search</h1>

<%= form_for search_path, method: :get do |f| %>
  <p>
    <%= f.label "Search for" %>
    <%= text_field_tag :q, params[:q] %>
    <%= submit_tag "Go", name: nil %>
  </p>
<% end %>

<ul>
  <% @homes.each do |home| %>
    <li>
      <h3>
        <%= link_to home.name, controller: "homes", action: "show", id: home._id%>
      </h3>
    </li>
  <% end %>
</ul>

任何建议将不胜感激!

【问题讨论】:

  • 能否也显示来自 ES 服务器的日志?
  • @janfoeh - 不知道如何访问 ES 服务器日志,您能指出正确的方向吗?
  • @Val 这个问题可能更适合你,因为我不熟悉 Elasticsearch :) 但如果我不得不猜测,我会先登录你的 Bonsai 仪表板。
  • 您确定在 Heroku ES 实例上正确设置了 homes 索引和映射类型吗?运行curl -XGET http://account.region.bonsai.io/homes/_search 时看到了什么,其中accountregion 应替换为您自己的设置。
  • @Val - 当我运行时,我得到:{"error":"IndexMissingException[[homes] missing]","status":404}

标签: ruby-on-rails ruby heroku elasticsearch bonsai-elasticsearch


【解决方案1】:

问题类似于this issue

解决方案涉及

  1. 运行任务highlighted here
  2. 确保elasticsearch.rake exists
  3. 最后,如果 404 仍然碰巧使用 curl -XPOST http://account.region.bonsai.io/homes 手动创建索引

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2017-06-16
    • 2020-02-25
    • 1970-01-01
    • 2013-02-12
    • 2017-07-22
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多