Elasticsearch 14

[Python] elasticsearch bulk insert contain _id

elasticserch에 데이터를 넣으면 UUID를 이용하여 자동으로 생성해주지만 실제 RDB와 연동하여 사용할 경우 ID를 PK과 값과 같이 관리할 일이 있다. Sample Dataframe import numpy as np import pandas as pd from datetime import datetime from elasticsearch import Elasticsearch from elasticsearch import helpers productId = ['AAA001', 'AAA002', 'AAA003' , 'AAA004', 'AAA005'] price = [15000, 11000, 21000, 25000, 14500] soldDay = [datetime(2020, 1, 2, 0, 0), ..

Elasticsearch 2020.03.04

[Python] Get elastic cluster health. (파이썬API를 이용한 elastic 클러스터 핼쓰 보기)

python elasticsearch API from elasticsearch import Elasticsearch es = Elasticsearch(hosts=' ',port=' ') cluster status print(es.cluster.health()['status']) green - green : 모든 샤드가 정상 - yellow : 프라이머리 샤드에는 할당되었지만 리플리카 샤드는 정상적으로 할당 되지 않음 - red : 일부 프라이머리 샤드가 클러스터에 정상적으로 할당되지 않음 cluster timed_out print(es.cluster.health()['timed_out']) False cluster unassigned_shards print(es.cluster.health()['unass..

Elasticsearch 2020.03.03

[Elasticsearch] index 생성시 shards(샤드)와 replicas(레플리카) 세팅

Version : 7.5.2 인덱스를 생성할 때, shards(샤드)와 replicas(레플리카)를 세팅하지 않으면 기본적으로 1:1로 세팅된다. 아래와 같이 마스터 2노드, 데이터 3노드로 클러스터를 지정하였지만, 세팅하지 않고 넣었을 시 자동으로 분산되지 않는 것을 볼 수 있다. index를 생성할 때, shards(샤드)와 replicas(리플리카)를 세팅할 수 있으며, 아래와 같이 3:2로 세팅을 해본다. PUT /index_test { "settings" : { "index" : { "number_of_shards" : 3, "number_of_replicas" : 2 } } } 정상적으로 index가 생성되었고, 아래와 같이 각 노드에 샤드 1, 레플리카 2개 생성되었다. elaelastics..

Elasticsearch 2020.02.21

[Python] Elasticsearch Monitoring

파이썬을 이용하여 Elasticsearch에 index 생성하고, 삭제하는 방법으로 모니터링 try: es = Elasticsearch(hosts=' ', port=' ') doc = ''' { "mappings": { "testindex": { "properties": { "msg": { "type": "keyword" } } } } }''' res = es.indices.create(index='testindex', body=doc) print('index create : %s' %res['acknowledged']) res = es.indices.delete(index='testindex') print('index delete : %s' %res['acknowledged']) except Excep..

Elasticsearch 2018.07.22