[엘라스틱서치] 주요 많이 사용하는 인제스트 파이프라인 모음 - forewalk/elastic GitHub Wiki

Elasticsearch

ingest pipeline


유용하게 많이 사용하는 인제스트들을 모았다.

  1. 문서 색인 관련 템플릿[attachment plugin 설치 필요]
PUT _ingest/pipeline/attachment
{"processors":[{"attachment":{"field":"data"}},{"remove":{"field":["data"]}},{"split":{"field":"attachment.content","separator":"\\-.[0-9].+\\-","ignore_failure":true}},{"trim":{"field":"attachment.content"}},{"gsub":{"field":"attachment.content","pattern":"\n","replacement":""}},{"gsub":{"field":"attachment.content","pattern":"\t","replacement":""}}]}
  1. 문서 색인시, 샘플링 등을 위한 랜덤 필드 생성
PUT _ingest/pipeline/add_info
{"processors":[{"script":{"source":"\n        ctx['sample_filter'] = new Random().nextInt(100)\n        "}}]}
  1. 타임스템프 찍기
PUT _ingest/pipeline/timestamp
{"processors":[{"set":{"field":"_source.timestamp","value":"{{_ingest.timestamp}}"}}]}
  1. 문서 내용 중에 특정 문자열 있으면 시퀀스 상승
PUT _ingest/pipeline/q_p
{"processors":[{"script":{"lang":"painless","source":"\n        if(ctx.containsKey(\"kk\")) {ctx.kk ++;}\n        else {ctx.kk = 1;}\n        "}}]}