在我的rails应用程序中,我正在使用elastic_searchable gem。我已正确安装它。 我这样使用它:
模型:
class Invoice < ActiveRecord::Base
elastic_searchable
end
控制器:
@invoices = Invoice.search(params[:query])
视图
<%= form_tag invoices_path, method: :get do %>
<%= text_field_tag :query, params[:query] %>
<%= submit_tag "Search", name: nil, class: 'btn' %>
<% end %>
启动弹性搜索服务及其运行
现在通过在搜索字段中提供一些查询,它会出现以下错误:
getaddrinfo: Name or service not known
完整追踪:
SocketError - getaddrinfo: Name or service not known:
/home/arif/.rvm/rubies/ruby-1.9.3-p327/lib/ruby/1.9.1/net/http.rb:762:in `initialize'
/home/arif/.rvm/rubies/ruby-1.9.3-p327/lib/ruby/1.9.1/net/http.rb:762:in `open'
/home/arif/.rvm/rubies/ruby-1.9.3-p327/lib/ruby/1.9.1/net/http.rb:762:in `block in connect'
/home/arif/.rvm/rubies/ruby-1.9.3-p327/lib/ruby/1.9.1/timeout.rb:54:in `timeout'
/home/arif/.rvm/rubies/ruby-1.9.3-p327/lib/ruby/1.9.1/timeout.rb:99:in `timeout'
/home/arif/.rvm/rubies/ruby-1.9.3-p327/lib/ruby/1.9.1/net/http.rb:762:in `connect'
/home/arif/.rvm/rubies/ruby-1.9.3-p327/lib/ruby/1.9.1/net/http.rb:755:in `do_start'
/home/arif/.rvm/rubies/ruby-1.9.3-p327/lib/ruby/1.9.1/net/http.rb:744:in `start'
/home/arif/.rvm/rubies/ruby-1.9.3-p327/lib/ruby/1.9.1/net/http.rb:1284:in `request'
(gem) rest-client-1.6.7/lib/restclient/net_http_ext.rb:51:in `request'
(gem) httparty-0.11.0/lib/httparty/request.rb:92:in `perform'
(gem) httparty-0.11.0/lib/httparty.rb:461:in `perform_request'
(gem) httparty-0.11.0/lib/httparty.rb:398:in `get'
(gem) elastic_searchable-3.0.2/lib/elastic_searchable.rb:40:in `request'
(gem) elastic_searchable-3.0.2/lib/elastic_searchable/active_record_extensions.rb:139:in `search'
(gem) activerecord-3.2.9/lib/active_record/relation/delegation.rb:14:in `block in search'
(gem) activerecord-3.2.9/lib/active_record/relation.rb:241:in `block in scoping'
(gem) activerecord-3.2.9/lib/active_record/scoping.rb:98:in `with_scope'
(gem) activerecord-3.2.9/lib/active_record/relation.rb:241:in `scoping'
(gem) activerecord-3.2.9/lib/active_record/relation/delegation.rb:14:in `search'
app/controllers/invoices_controller.rb:19:in `index'
(gem) actionpack-3.2.9/lib/action_controller/metal/implicit_render.rb:4:in `send_action'
(gem) actionpack-3.2.9/lib/abstract_controller/base.rb:167:in `process_action'
(gem) actionpack-3.2.9/lib/action_controller/metal/rendering.rb:10:in `process_action'
(gem) actionpack-3.2.9/lib/abstract_controller/callbacks.rb:18:in `block in process_action'
(gem) activesupport-3.2.9/lib/active_support/callbacks.rb:515:in `block (2 levels) in _run__245382556__process_action__717469624__callbacks'
(gem) activesupport-3.2.9/lib/active_support/callbacks.rb:215:in `block in _conditional_callback_around_782'
app/controllers/application_controller.rb:23:in `scope_current_account'
(gem) activesupport-3.2.9/lib/active_support/callbacks.rb:214:in `_conditional_callback_around_782'
(gem) activesupport-3.2.9/lib/active_support/callbacks.rb:492:in `block in _run__245382556__process_action__717469624__callbacks'
(gem) activesupport-3.2.9/lib/active_support/callbacks.rb:215:in `block in _conditional_callback_around_781'
(gem) activesupport-3.2.9/lib/active_support/callbacks.rb:326:in `around'
(gem) activesupport-3.2.9/lib/active_support/callbacks.rb:310:in `_callback_around_171'
(gem) activesupport-3.2.9/lib/active_support/callbacks.rb:214:in `_conditional_callback_around_781'
(gem) activesupport-3.2.9/lib/active_support/callbacks.rb:447:in `_run__245382556__process_action__717469624__callbacks'
(gem) activesupport-3.2.9/lib/active_support/callbacks.rb:405:in `__run_callback'
(gem) activesupport-3.2.9/lib/active_support/callbacks.rb:385:in `_run_process_action_callbacks'
(gem) activesupport-3.2.9/lib/active_support/callbacks.rb:81:in `run_callbacks'
(gem) actionpack-3.2.9/lib/abstract_controller/callbacks.rb:17:in `process_action'
(gem) actionpack-3.2.9/lib/action_controller/metal/rescue.rb:29:in `process_action'
(gem) actionpack-3.2.9/lib/action_controller/metal/instrumentation.rb:30:in `block in process_action'
(gem) activesupport-3.2.9/lib/active_support/notifications.rb:123:in `block in instrument'
(gem) activesupport-3.2.9/lib/active_support/notifications/instrumenter.rb:20:in `instrument'
(gem) activesupport-3.2.9/lib/active_support/notifications.rb:123:in `instrument'
(gem) actionpack-3.2.9/lib/action_controller/metal/instrumentation.rb:29:in `process_action'
(gem) actionpack-3.2.9/lib/action_controller/metal/params_wrapper.rb:207:in `process_action'
(gem) activerecord-3.2.9/lib/active_record/railties/controller_runtime.rb:18:in `process_action'
(gem) actionpack-3.2.9/lib/abstract_controller/base.rb:121:in `process'
(gem) actionpack-3.2.9/lib/abstract_controller/rendering.rb:45:in `process'
(gem) actionpack-3.2.9/lib/action_controller/metal.rb:203:in `dispatch'
(gem) actionpack-3.2.9/lib/action_controller/metal/rack_delegation.rb:14:in `dispatch'
(gem) actionpack-3.2.9/lib/action_controller/metal.rb:246:in `block in action'
(gem) actionpack-3.2.9/lib/action_dispatch/routing/route_set.rb:73:in `call'
(gem) actionpack-3.2.9/lib/action_dispatch/routing/route_set.rb:73:in `dispatch'
(gem) actionpack-3.2.9/lib/action_dispatch/routing/route_set.rb:36:in `call'
(gem) journey-1.0.4/lib/journey/router.rb:68:in `block in call'
(gem) journey-1.0.4/lib/journey/router.rb:56:in `each'
(gem) journey-1.0.4/lib/journey/router.rb:56:in `call'
(gem) actionpack-3.2.9/lib/action_dispatch/routing/route_set.rb:601:in `call'
(gem) better_errors-0.3.2/lib/better_errors/middleware.rb:51:in `app_call'
(gem) better_errors-0.3.2/lib/better_errors/middleware.rb:45:in `call'
lib/set_account_context.rb:14:in `call'
(gem) pdfkit-0.5.2/lib/pdfkit/middleware.rb:16:in `call'
(gem) warden-1.2.1/lib/warden/manager.rb:35:in `block in call'
(gem) warden-1.2.1/lib/warden/manager.rb:34:in `catch'
(gem) warden-1.2.1/lib/warden/manager.rb:34:in `call'
(gem) actionpack-3.2.9/lib/action_dispatch/middleware/best_standards_support.rb:17:in `call'
(gem) rack-1.4.1/lib/rack/etag.rb:23:in `call'
(gem) rack-1.4.1/lib/rack/conditionalget.rb:25:in `call'
(gem) actionpack-3.2.9/lib/action_dispatch/middleware/head.rb:14:in `call'
(gem) actionpack-3.2.9/lib/action_dispatch/middleware/params_parser.rb:21:in `call'
(gem) actionpack-3.2.9/lib/action_dispatch/middleware/flash.rb:242:in `call'
(gem) rack-1.4.1/lib/rack/session/abstract/id.rb:205:in `context'
(gem) rack-1.4.1/lib/rack/session/abstract/id.rb:200:in `call'
(gem) actionpack-3.2.9/lib/action_dispatch/middleware/cookies.rb:341:in `call'
(gem) activerecord-3.2.9/lib/active_record/query_cache.rb:64:in `call'
(gem) activerecord-3.2.9/lib/active_record/connection_adapters/abstract/connection_pool.rb:479:in `call'
(gem) actionpack-3.2.9/lib/action_dispatch/middleware/callbacks.rb:28:in `block in call'
(gem) activesupport-3.2.9/lib/active_support/callbacks.rb:405:in `_run__686332576__call__479919382__callbacks'
(gem) activesupport-3.2.9/lib/active_support/callbacks.rb:405:in `__run_callback'
(gem) activesupport-3.2.9/lib/active_support/callbacks.rb:385:in `_run_call_callbacks'
(gem) activesupport-3.2.9/lib/active_support/callbacks.rb:81:in `run_callbacks'
(gem) actionpack-3.2.9/lib/action_dispatch/middleware/callbacks.rb:27:in `call'
(gem) actionpack-3.2.9/lib/action_dispatch/middleware/reloader.rb:65:in `call'
(gem) actionpack-3.2.9/lib/action_dispatch/middleware/remote_ip.rb:31:in `call'
(gem) actionpack-3.2.9/lib/action_dispatch/middleware/debug_exceptions.rb:16:in `call'
(gem) actionpack-3.2.9/lib/action_dispatch/middleware/show_exceptions.rb:56:in `call'
(gem) railties-3.2.9/lib/rails/rack/logger.rb:32:in `call_app'
(gem) railties-3.2.9/lib/rails/rack/logger.rb:16:in `block in call'
(gem) activesupport-3.2.9/lib/active_support/tagged_logging.rb:22:in `tagged'
(gem) railties-3.2.9/lib/rails/rack/logger.rb:16:in `call'
(gem) quiet_assets-1.0.2/lib/quiet_assets.rb:18:in `call_with_quiet_assets'
(gem) actionpack-3.2.9/lib/action_dispatch/middleware/request_id.rb:22:in `call'
(gem) rack-1.4.1/lib/rack/methodoverride.rb:21:in `call'
(gem) rack-1.4.1/lib/rack/runtime.rb:17:in `call'
(gem) activesupport-3.2.9/lib/active_support/cache/strategy/local_cache.rb:72:in `call'
(gem) rack-1.4.1/lib/rack/lock.rb:15:in `call'
(gem) actionpack-3.2.9/lib/action_dispatch/middleware/static.rb:62:in `call'
(gem) railties-3.2.9/lib/rails/engine.rb:479:in `call'
(gem) railties-3.2.9/lib/rails/application.rb:223:in `call'
(gem) rack-1.4.1/lib/rack/content_length.rb:14:in `call'
(gem) railties-3.2.9/lib/rails/rack/log_tailer.rb:17:in `call'
(gem) thin-1.5.1/lib/thin/connection.rb:81:in `block in pre_process'
(gem) thin-1.5.1/lib/thin/connection.rb:79:in `catch'
(gem) thin-1.5.1/lib/thin/connection.rb:79:in `pre_process'
(gem) thin-1.5.1/lib/thin/connection.rb:54:in `process'
(gem) thin-1.5.1/lib/thin/connection.rb:39:in `receive_data'
(gem) eventmachine-1.0.3/lib/eventmachine.rb:187:in `run_machine'
(gem) eventmachine-1.0.3/lib/eventmachine.rb:187:in `run'
(gem) thin-1.5.1/lib/thin/backends/base.rb:63:in `start'
(gem) thin-1.5.1/lib/thin/server.rb:159:in `start'
(gem) rack-1.4.1/lib/rack/handler/thin.rb:13:in `run'
(gem) rack-1.4.1/lib/rack/server.rb:265:in `start'
(gem) railties-3.2.9/lib/rails/commands/server.rb:70:in `start'
(gem) railties-3.2.9/lib/rails/commands.rb:55:in `block in <top (required)>'
(gem) railties-3.2.9/lib/rails/commands.rb:50:in `tap'
(gem) railties-3.2.9/lib/rails/commands.rb:50:in `<top (required)>'
script/rails:6:in `require'
script/rails:6:in `<main>'
我需要配置一些东西还是我做错了什么?提前致谢