On my local machine, I am using elasticsearch
, ruby
, sinatra
and the stretcher
gem.
I get the following error:
faraday.rb:99:in `method_missing': undefined method `load_autoloaded_constants' for #<Faraday::Connection:0x9b9f218> (NoMethodError)
The truncated ruby code is:
require 'sinatra'
require 'stretcher'
configure do
ES = Stretcher::Server.new('http://localhost:9200')
end
class Products
def self.match(text)
ES.index(:products).search size: 1000, query: {
multi_match: { query: text, fields: [:title, :description] }
}
end
end
get "/" do
erb :index
end
get "/:search" do
erb :result, locals: { products: Products.match(params[:search]) }
end
post "/" do
unless ES.index(:products).exists?
# create index if not exists
ES.index(:products).create(mappings: {
product: {
properties: {
title: {type: :string},
price: {type: :integer},
description: {type: :string}
}
}
})
end
All help gratefully received.
When I install stretcher it installs faraday_middleware-multi_json 0.0.6 and faraday 0.9.0 and faraday_middleware 0.9.1 by default.