I'm expecting to be able to run Model.import(force: true)
in the rails console and move forward with configuring my Elastic search using the elasticsearch-rails
gem
This is the error/backtrace I get though.
NoMethodError: undefined method `params_encoder' for {"timeout"=>300, :proxy=>nil}:Hash
from /Users/Lois/.rvm/gems/ruby-2.4.0/gems/faraday-0.14.0/lib/faraday/request.rb:60:in `url'
Create new rails app
rails new elasticrails
Add elastic-search gems:
gem 'elasticsearch-model', git: 'git://github.com/elastic/elasticsearch-rails.git', branch: 'master'
gem 'elasticsearch-rails', git: 'git://github.com/elastic/elasticsearch-rails.git', branch: 'master'
Bundle install:
bundle install
Add model:
rails g model Price price:integer
Setup db:
rails db:create db:migrate
Include elastic-search-rails to model file:
# app/models/price.rb
class Price
include Elasticsearch::Model
include Elasticsearch::Model::Callbacks
index_name([Rails.env,base_class.to_s.pluralize.underscore].join('_'))
...
end
Open rails console:
rails console
Run import command:
Price.import(force: true)
Hi @PrimeTimeTran,
thanks for the details but having also the full backtrace would help in this case rather than just the first line. I might notice the issue immediately with that, otherwise I'll need to setup the project following your steps, but that will take significantly longer.
Hey @iMacTia,
That is the entire trace.
OK! That’s strange...
I’ll try to replicate it then and see why that happens. However I’d suggest raising this also with the elasticsearch-model
or elasticsearch-Rails
maintainers as it might be due to the way they use Faraday internally
Yeah, I've already opened up an issue on elasticsearch-rails, but I don't know where in their gem it's getting called from so wasn't sure what else I could tell them that's useful.
Also thanks for looking into this~! We appreciate your work
I made a mistake. It has to do with the initializers I did in this blog post.
https://medium.com/@thecolorfulcrayon/configuring-elasticsearch-on-rails-8bcbe973e9e7
I'm closing this issue. My apologies. Thanks for your time.
No worries!
Thank you very much for the update.
For anyone who lands here from google, make sure to use deep_symbolize_keys
when loading your config file as if they are mix and match you will see this problem.
@mattdrewitt thank you for this!
Most helpful comment
For anyone who lands here from google, make sure to use
deep_symbolize_keys
when loading your config file as if they are mix and match you will see this problem.