在我安装了“elasticsearch-model”和“elasticsearch-rails”gems 的 rails 应用程序中,并在默认端口上运行 elasticsearch (v5.1.1) 和一个看起来像这样的模型
class Article
include Mongoid::Document
include Elasticsearch::Model
include Elasticsearch::Model::Callbacks
field :title, type: String
field :author, type: String
index_name "articles-#{Rails.env}"
end
Run Code Online (Sandbox Code Playgroud)
初始化程序是这样的
Elasticsearch::Model.client = Elasticsearch::Client.new host: ENV['ELASTICSEARCH_URL'] || "http://localhost:9200/"
Run Code Online (Sandbox Code Playgroud)
当我尝试导入或创建索引时
Article.import force:true
Article.__elasticsearch__.create_index! force: true
Run Code Online (Sandbox Code Playgroud)
我收到以下错误
Elasticsearch::Transport::Transport::Errors::BadRequest: [400] No handler found for uri [//articles-development] and method [DELETE]
from /Users/bgr/.rvm/gems/ruby-2.3.0/gems/elasticsearch-transport-1.0.17/lib/elasticsearch/transport/transport/base.rb:201:in `__raise_transport_error'
from /Users/bgr/.rvm/gems/ruby-2.3.0/gems/elasticsearch-transport-1.0.17/lib/elasticsearch/transport/transport/base.rb:312:in `perform_request'
from /Users/bgr/.rvm/gems/ruby-2.3.0/gems/elasticsearch-transport-1.0.17/lib/elasticsearch/transport/transport/http/faraday.rb:20:in `perform_request'
from /Users/bgr/.rvm/gems/ruby-2.3.0/gems/elasticsearch-transport-1.0.17/lib/elasticsearch/transport/client.rb:128:in `perform_request'
Run Code Online (Sandbox Code Playgroud) 当我将函数分配给变量并尝试调用它时。它抛出错误“返回的参数太多”
package main
import "fmt"
func main() {
first_name := "Hello"
last_name := "World!"
full_name := func() {
return first_name
}
fmt.Println(first_name)
fmt.Println(last_name)
fmt.Println(full_name)
}
Run Code Online (Sandbox Code Playgroud)