英文:
elastic / elasticsearch-ruby gem || How call put_lifecycle method
问题
我正在使用 elasticsearch-ruby (7.15.0)。
我想创建一个生命周期策略。
我是这样做的....
```ruby
$elastic ||= Elasticsearch::Client.new(
host: $settings['business.elastic_server'],
user: $settings['business.elastic_username'],
password: $settings['business.elastic_password'],
log: false
)
$elastic.ilm.put_lifecycle(
policy: 'my_policy',
body: {"policy":{"phases":{"delete":{"min_age":"30d","actions":{"delete":{}}}}}}
)
然后我得到了:
elasticsearch-7.15.0/lib/elasticsearch.rb:43:in `method_missing': undefined method `ilm'
调用 put_lifecycle 方法的正确方式是什么?
谢谢
<details>
<summary>英文:</summary>
I'm using elasticsearch-ruby (7.15.0)
I want to create a lifecycle policy.
I'm doing it like this....
```ruby
$elastic ||= Elasticsearch::Client.new(
host: $settings['business.elastic_server'],
user: $settings['business.elastic_username'],
password: $settings['business.elastic_password'],
log: false
)
$elastic.ilm.put_lifecycle(
policy: 'my_policy',
body: {"policy":{"phases":{"delete":{"min_age":"30d","actions":{"delete":{}}}}}}
)
Then I got.
elasticsearch-7.15.0/lib/elasticsearch.rb:43:in `method_missing': undefined method `ilm'
What is the proper way to call put_lifecycle method?
Thanks
答案1
得分: 1
最后,我决定将我的Gemfile升级为gem 'elasticsearch','8.6.0',并且工作得很好。
这个解释由Fernando Briano(picandocodigo)提供,正如@vasily-kolesnikov在评论中所说
在客户端的7.15版本中,索引生命周期管理API可以通过elasticsearch-xpack gem获得。你是否在你的代码中引用了它?代码的其余部分看起来没问题,如果你已经引入了elasticsearch-xpack,它应该可以工作。如果这是问题,请告诉我,谢谢!
最佳选择是使用与服务器次要版本相同的客户端次要版本。
英文:
Finally I decided to upgrade my Gemfile with gem 'elasticsearch', '8.6.0' and works perfect.
The explanation has been provided by Fernando Briano (picandocodigo ) as @vasily-kolesnikov said in a comment
In version 7.15 of the client, the index lifecycle management APIs are available through the elasticsearch-xpack gem. Have you required it in your code? The rest of the code looks ok, it should work if you have required elasticsearch-xpack.
Let me know if that's the issue, thanks!
The best option is to use the client minor version equal to the server's minor version.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论