Skip to content

Instantly share code, notes, and snippets.

echo -n $(curl -s localhost:9200 | python -c 'import sys,json; j = json.load(sys.stdin); print j["version"]["number"]') ""
curl -s localhost:9200/_nodes/_local/jvm | python -c 'import sys,json; j = json.load(sys.stdin); print j["nodes"].items()[0][1]["jvm"]["version"]'
#!/bin/sh
curl -s localhost:9200/_cluster/nodes\?all | python -c'
import sys, json
d = json.load(sys.stdin)
for id, n in d["nodes"].iteritems():
print "%s %s %s %s" % (n["version"],
n["jvm"]["vm_name"],
n["jvm"]["version"],
n["transport"]["bound_address"])
@drewr
drewr / recovery.sh
Last active December 20, 2015 20:38
curl -s p.draines.com/shards.sh | sh | fgrep ' r ' | sort >/tmp/1
sleep 30
curl -s p.draines.com/shards.sh | sh | fgrep ' r ' | sort >/tmp/2
diff -u /tmp/[12]
curl -XDELETE localhost:9200/esnoob >/dev/null
curl -XPUT localhost:9200/esnoob -d'
{
"mappings": {
"t": {
"properties": {
"address": {
"type": "string"
}
@drewr
drewr / slides.txt
Created September 15, 2013 07:29
Getting started with ES
=-= 1
#!/bin/bash
curl -XDELETE localhost:9200/test >/dev/null
curl -XPUT localhost:9200/test -d'
{
"number_of_replicas": 0,
"number_of_shards": 1
}
@drewr
drewr / x-opaque-id.sh
Created October 23, 2013 14:52
Example of X-Opaque-Id
#!/bin/sh
curl -XDELETE localhost:9200/foo >/dev/null
curl -XPUT localhost:9200/foo/t/1 -d'{"field":"value"}'; echo
curl -XPOST localhost:9200/foo/_refresh; echo
curl -v -H X-Opaque-Id:FOOOOOOO localhost:9200/foo/_search; echo
@drewr
drewr / script-score.sh
Created October 23, 2013 22:50
Example of function_score using the script_score function. This achieves a result similar to creating a script field and then sorting descending by that dynamic value.
#!/bin/sh
curl -XDELETE localhost:9200/foo >/dev/null
curl -XPOST localhost:9200/foo/t -d'
{
"clicks": 10,
"impressions": 1000,
"when": "2013-10-01"
}
@drewr
drewr / import-bulks
Last active December 26, 2015 23:59
Simple bulk-indexing
#!/bin/sh
index=$1
find . -name \*.bulk.gz | while read i; do
gzip -cd $i | curl -XPOST localhost:9200/${index}/_bulk -d@- >/dev/null
done