在我的本地机器上,我正在使用elasticsearch
,ruby
和gem。sinatra
stretcher
我收到以下错误:
faraday.rb:99:in `method_missing': undefined method `load_autoloaded_constants' for #<Faraday::Connection:0x9b9f218> (NoMethodError)
截断的 ruby 代码是:
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
感谢所有帮助。
当我安装担架时,它默认安装 faraday_middleware-multi_json 0.0.6 和 faraday 0.9.0 和 faraday_middleware 0.9.1。