1. elasticsearch cluster 의 health 체크

: esClient.cluster.health => 응답으로 받은 데이터는 hash 형태의 리턴값

 

{"cluster_name"=>"elasticsearch", "status"=>"yellow", "timed_out"=>false, "number_of_nodes"=>1, "number_of_data_nodes"=>1, "active_primary_shards"=>15, "active_shards"=>15, "relocating_shards"=>0, "initializing_shards"=>0, "unassigned_shards"=>15, "delayed_unassigned_shards"=>0, "number_of_pending_tasks"=>0, "number_of_in_flight_fetch"=>0, "task_max_waiting_in_queue_millis"=>0, "active_shards_percent_as_number"=>50.0}

 

2. 전체 인덱스 확인

: esClient.cat.indices => 응답으로 받은 데이터는 string 형태의 리턴값

: shell 로 코드를 구성한다면 다음과 같다.

#!/bin/bash

curl -XGET localhost:9200/_cat/indices?pretty

 

3. document indexing

: shell 로 코드를 구성한다면 다음과 같다.

#!/bin/bash

curl -X POST "localhost:9200/index_data" -H "Content-Type: application/json" -d'

{

  "name": "KimJunHyeon"

}' 

 

4. delete_by_query

: 인덱스의 껍데기 (mapping)을 유지한 상태에서 모든 document를 지워야할 경우가 생긴다. 그럴경우 

delete_by_query 문을 사용한다.

 

: shell 로 코드를 구성한다면 다음과 같다.

#!/bin/bash

curl -X POST "localhost:9200/index_data/_delete_by_query" -H "Content-Type: application/json" -d'
{
  "query": {
     "match_all": {}
  }
}'

 

'언어 > Ruby' 카테고리의 다른 글

logstash ruby filter elasticsearch bulk insert  (0) 2020.07.22
ruby json 파일 읽기  (0) 2020.07.02
ruby elasticsearch client  (0) 2020.05.26
cea(ver3)  (0) 2016.02.27
class  (0) 2016.02.27