LoginSignup
0
0

More than 1 year has passed since last update.

[000] Ruby の elasticsearch client パッケージを使って Elasticsearch 7.14 を操作してみる ... 検証環境構築編

Last updated at Posted at 2021-08-14
シリーズトップページ
https://qiita.com/robozushi10/items/2c8b6951ee342b013974

概要

Ruby の Elasticsearch Client を使って Elasticsearch 7.14 で REST API の操作する.

検証環境の構築手順

1. 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コンテナの立ち上げ(説明なし)

2. サンプルデータ「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章)

3. Elasticsearch Client を導入した Ruby on Docker 環境を用意する

下記リポジトリには、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 で操作をしてみる.

image.png

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0