ohmyzsh/plugins/elasticsearch/elasticsearch.plugin.zsh
Fedele Mantuano aa9a96f327 Added GET API Elasticsearch plugin
Manage _cat API

Added PUT, POST, DELETE commands.
Added options for autocomplete
2015-08-27 21:26:56 +02:00

45 lines
1.2 KiB
Bash

# ------------------------------------------------------------------------------
# Description
# -----------
#
# You can use Elastichsearch GET API like in Marvel sense console:
# GET /
# GET _cluster/health
# GET _nodes/stats
# GET _stats/fielddata?fields=*
# GET _nodes/stats/indices/fielddata?fields=*
#
# You have do install json_reformat (http://dev.man-online.org/package/main/yajl-tools/)
# to format json
#
# ------------------------------------------------------------------------------
# Author
# -------
#
# * Fedele Mantuano (Twitter: @fedelemantuano)
#
# ------------------------------------------------------------------------------
alias ech='GET _cluster/health'
alias ecs='GET _cluster/state'
alias ens='GET _nodes/stats'
alias esf='GET _stats/fielddata'
# GET
if which json_reformat > /dev/null 2>&1; then
GET() { curl -s -XGET http://localhost:9200/"$@" | json_reformat 2>/dev/null || curl -s -XGET http://localhost:9200/"$@" }
else
GET() { curl -s -XGET http://localhost:9200/"$@" }
fi
# HEAD
HEAD() { curl -s -XHEAD -i http://localhost:9200/"$@" }
# DELETE
DELETE() { curl -s -XDELETE http://localhost:9200/"$@" }
# PUT
PUT() { curl -s -XPUT http://localhost:9200/"$@" }
# POST
POST() { curl -s -XPOST http://localhost:9200/"$@" }