[ Elastic Search ] Indexing

김우경·2020년 11월 15일
0
post-thumbnail

Elastic Search 데이터 색인

1. 새 데이터 삽입

e.g. timeline에 데이터 post

- body

{
	"contentId": "1283",
	
	"ymd": "2020-11-15",

	"usestate": "",

	"regdate":	"2020-11-16 11:00:13"

}
  • doc id 지정하지 않을 시 elastic search 에서 자동으로 id값 부여

2. 기존 데이터 update

방법 1 POST method

: insert와 같은 방법으로 post method를 이용해 update 하고자 하는 id의 데이터를 update
-> 이때 기존의 데이터도 같이 입력해 주어야 함

문제점
-> update하고자 하는 데이터의 id를 기억해야함
-> update 시 기존 reg값은 유지하고(기존 값 그대로 post) upddate를 현재시각으로 update해줘야함

방법 2 update_by_query 이용

-body

  • update하고자 하는 field만 update 가능
  • 여러 parameter 사용 가능 (source에서 ,가 아닌 ;로 구분짓기)
  • 파라미터 대신 직접 string 이나 정수로 비교 가능

(참고: https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-update-by-query.html)

문제점
-> update할 데이터가 지나치게 많으면 멈출 수 있음
- script 이용, kibana에서 sql 사용 등

profile
Hongik CE

0개의 댓글