elasticsearch-ruby:转换

elasticsearch-ruby: transforms

我们可以读入elasticsearch-ruby CHANGELOG (Vewsion 7.7.0) That we have New API Endpoints availables. Transforms included. Here they are.

我们正在使用 elasticsearch-ruby 7.15.0。但是不知道怎么用。

这是我的例子...

require 'elasticsearch'

elasticsearch = Elasticsearch::Client.new(
  cloud_id: '******',
  user: '******',
  password: '******',
  log: false
)

elasticsearch.transform.stop_transform transform_id: 'my_transform' 

但是我们得到一个错误...

/usr/local/rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/elasticsearch-7.15.0/lib/elasticsearch.rb:43:in `method_missing': undefined method `transform' for #<Elasticsearch::Client:0x0000556a2ad72bb8> (NoMethodError)

代码在文件夹 /lib/elasticsearch/api/actions 中。就像指数一样。

我们可以使用这样的索引...

if elasticsearch.indices.exists? index: 'mi_index'
  <do what ever we want>
end 

我们在文档中找不到任何内容。 https://rubydoc.info/gems/elasticsearch-api/Elasticsearch/API

那么,我们如何使用转换端点?

Thanks to @picandocodigo.

The elasticsearch-xpack gem was deprecated and its endpoints (like those under the transform namespace) were merged into elasticsearch-api, but only for main and the 8.x version. In 7.x versions of the client, you still need to install and require the elasticsearch-xpack gem. You can see the code here for 7.15.

So you need to do something like:

require 'elasticsearch'
require 'elasticsearch/xpack'

client = Elasticsearch::Client.new
client.transform.stop_transform(transform_id: 'my_transform' )