[elasticsearch] 색인 생성 스크립트.

Elastic/Elasticsearch 2014. 1. 8. 12:08

색인 스키마를 json 파일로 만들어 놓고 rest api 로 생성 할 때 유용한 스크립트 입니다.

그냥 제가 사용하기 편할라고 대충 만들어 놓은거랍니다.


#!/bin/bash

size=$#

if [ $size -ne 3 ]; then
    echo "Usage: create_index.sh IP:PORT INDICE SCHEME_FILE";
    echo "Example: create_index.sh localhost:9200 idx_local schema.json";
    exit 0;
fi

serviceUri=$1
indice=$2
schema=$3

curl -XDELETE 'http://'$serviceUri'/'$indice

curl -XPUT 'http://'$serviceUri'/'$indice -d @$schema


: