使用 Ruby 的 Elasticsearch 客户端包来操作 Elasticsearch 7.14,以进行验证环境的构建
总结
使用Ruby的Elasticsearch客户端在Elasticsearch 7.14上操作REST API。
建立验证环境的步骤
使用docker-compose在本地计算机上启动Elasticsearch。
Elasticsearch和Kibana的端口号有些特殊。
$ git clone -b Qiita-02 git@github.com:robozushi10/qiita-efk.git
$ cd qiita-efk
$ docker-compose build --no-cache
$ docker-compose up -d
在原有的源头上引述:
[02] 搭建EFK(Elasticsearch + Fluentd + Kibana)…启动Docker容器(无解释)
将“Shakespeare”样本数据注册到环境1中。
「Shakespeare」是Elasticsearch教程中公开的超过11万个数据。
$ curl -O https://download.elastic.co/demos/kibana/gettingstarted/7.x/shakespeare.json
$ curl -X POST -H "Content-Type: application/x-ndjson" \
localhost:29200/_bulk --data-binary @shakespeare.json
在Elasticsearch 7.14版本中,我尝试进行了《? 数据分析基础构建入门》一书的写作(第16章)。
准备一个在 Docker 上安装了 Elasticsearch Client 的 Ruby 环境。
在下面的存储库中,已经准备好了一个定义了 Elasticsearch 包的 Gemfile。
$ git clone git@github.com:robozushi10/qiita-ruby3.0-docker
$ cd qiita-ruby3.0-docker
$ docker-compose build --no-cache
$ docker-compose up -d
请用中文进行同义转述,只需一个选项:
由于以上环境已经建立好了,那么现在可以尝试使用Ruby进行操作了。
