【问题标题】:How to insert data in elastic search using ruby如何使用 ruby​​ 在弹性搜索中插入数据
【发布时间】:2018-02-23 19:36:56
【问题描述】:

我正在尝试使用 Elasticsearch 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

还有其他方法吗?

【问题讨论】:

    标签: ruby elasticsearch rubygems


    【解决方案1】:

    您收到此错误是因为Actions 只是一个模块,包含在Elasticsearch::API::Indices::IndicesClient 中。

    你应该初始化你的客户端并像这样调用它:

    client.indicies.put_template(args)
    

    无论如何,我强烈建议您看看chewy。这是一个非常酷的 elasticsearch gem,由 toptal 维护。

    【讨论】:

      猜你喜欢
      • 2015-12-12
      • 2014-03-17
      • 1970-01-01
      • 2017-12-14
      • 2015-05-26
      • 1970-01-01
      • 2012-09-07
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多