Skip to content

Instantly share code, notes, and snippets.

@MatthewRiggott
Created May 22, 2018 20:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MatthewRiggott/d9228ead719a5756a935652ae5f9d304 to your computer and use it in GitHub Desktop.
Save MatthewRiggott/d9228ead719a5756a935652ae5f9d304 to your computer and use it in GitHub Desktop.
Run Elastic Search in shell with verbose output
# For Elastic Search version 5.6
# Credit to https://opensourceconnections.com/blog/2016/04/21/run-elasticsearch-in-your-shell/
# This mostly worked, I had to remove the argument for default.path.home and prepend each arg with -E (ES version 5.0+ breaking change)
#
# Add the following to your path and load (for ubuntu, actual paths may vary)
# Elastic Search Settings --
# ES_JAVA_OPTS="-Des.logger.level=INFO"
# LOG_DIR="/var/log/elasticsearch"
# DATA_DIR="/var/lib/elasticsearch"
# CONF_DIR="/etc/elasticsearch"
# ES_HOME="/usr/share/elasticsearch"
#
# Finally you should now be able to manually run ElasticSearch
sudo -u elasticsearch ES_JAVA_OPTS=$ES_JAVA_OPTS bash -x $ES_HOME/bin/elasticsearch --verbose -Edefault.path.logs=$LOG_DIR -Edefault.path.data=$DATA_DIR -Edefault.path.conf=$CONF_DIR
# Get detailed ES instance output
curl -XGET 'http://localhost:9200/_nodes?pretty'
# List all indexes
curl -X GET "localhost:9200/_cat/indices?v"
# Healthcheck
curl -X GET "localhost:9200/_cat/health?v"
# Create Document
curl -X PUT "localhost:9200/customer/_doc/1?pretty" -H 'Content-Type: application/json' -d'
{
"name": "John Doe"
}
'
# Query Document
curl -X GET "localhost:9200/customer/_doc/1?pretty"
# Delete Document
curl -X DELETE "localhost:9200/customer?pretty"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment