我正在尝试使用弹性搜索PUT在ruby中使用Elasticsearch gem插入数据,但是我找到了找不到方法的错误。
Here is the sample code:
def self.insert_data_in_es
name = (here I am giving the url)
body = (actual data)
Elasticsearch::API::Indices::Actions.put_template(name: name, body:
body)
end
Error :
NoMethodError: undefined method `put_template' for Elasticsearch::API::Indices::Actions:Module
还有其他办法吗?
答案 0 :(得分:1)
您收到此错误是因为Actions
只是一个模块,包含在Elasticsearch::API::Indices::IndicesClient
中。
您应该初始化您的客户并将其称为:
client.indicies.put_template(args)
无论如何,我强烈建议你看看chewy。它是非常酷的弹性搜索宝石,由toptal维护。