Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env bash
- DEFAULT_HOST=localhost
- DEFAULT_PORT=9200
- INPUT_DATA_INDEX=raw-data-index
- RULE_RUNTIME_EVENT_INDEX=rule-runtime-event-index
- AGENDA_EVENT_INDEX=agenda-event-index
- while getopts "h:p:" opt; do
- case $opt in
- h)
- echo "-h was triggered, Parameter: $OPTARG" >&2
- HOST=$OPTARG
- ;;
- p)
- echo "-p was triggered, Parameter: $OPTARG" >&2
- PORT=$OPTARG
- ;;
- \?)
- printf "Usage: %s [-h hostname] [-p port]\n" $0
- printf "Defaults: \n\thostname:\t${DEFAULT_HOST}\n\tport:\t\t${DEFAULT_PORT}"
- exit 2
- ;;
- esac
- done
- #
- if [[ -z ${HOST} ]]; then
- HOST=$DEFAULT_HOST
- fi
- if [[ -z ${PORT} ]]; then
- PORT=$DEFAULT_PORT
- fi
- printf "ES URL set to: ${HOST}:${PORT}\n"
- printf "\n"
- printf "Creating '${INPUT_DATA_INDEX}' index mappings...\n"
- curl -XDELETE http://${HOST}:${PORT}/${INPUT_DATA_INDEX}
- curl -XPUT http://${HOST}:${PORT}/${INPUT_DATA_INDEX} -d '
- {
- "mappings" : {
- "measurement": {
- "properties" : {
- "timestamp": {
- "type": "date",
- "format": "epoch_millis"
- },
- "timestamp2": {
- "type": "date",
- "format": "epoch_millis"
- },
- "sensorId": {
- "type":"string",
- "index": "not_analyzed"
- },
- "speed": {
- "type":"integer"
- }
- }
- }
- }
- }'
- printf "\n"
- printf "Creating '${RULE_RUNTIME_EVENT_INDEX}' index mappings...\n"
- curl -XDELETE http://${HOST}:${PORT}/${RULE_RUNTIME_EVENT_INDEX}
- curl -XPUT http://${HOST}:${PORT}/${RULE_RUNTIME_EVENT_INDEX} -d '
- {
- "mappings" : {
- "rule-runtime-event" : {
- "properties" : {
- "timestamp": {
- "type": "date",
- "format": "epoch_millis"
- },
- "eventType" : {
- "type" : "string",
- "index": "not_analyzed"
- },
- "eventMsg" : {
- "type" : "string"
- },
- "sensor" : {
- "type" : "string",
- "index": "not_analyzed"
- },
- "speed" : {
- "type" : "double"
- }
- }
- }
- }
- }'
- printf "\n"
- printf "Creating '${AGENDA_EVENT_INDEX}' index mappings...\n"
- curl -XDELETE http://${HOST}:${PORT}/${AGENDA_EVENT_INDEX}
- curl -XPUT http://${HOST}:${PORT}/${AGENDA_EVENT_INDEX} -d '
- {
- "mappings" : {
- "agenda-event" : {
- "properties" : {
- "timestamp": {
- "type": "date",
- "format": "epoch_millis"
- },
- "eventType" : {
- "type" : "string",
- "index": "not_analyzed"
- },
- "ruleName" : {
- "type" : "string"
- },
- "message": {
- "type":"string"
- },
- "sensor" : {
- "type" : "string",
- "index": "not_analyzed"
- },
- "speed" : {
- "type" : "double"
- }
- }
- }
- }
- }'
- printf "\n"
- printf "Done!\n"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement