Skip to content

Instantly share code, notes, and snippets.

@drewr
drewr / twitter-mapping.json
Created April 8, 2014 15:32
Sample twitter settings
{
"twitter": {
"mappings": {
"status": {
"_all": {
"enabled": false
},
"_size": {
"enabled": true,
"store": true
@drewr
drewr / tribe-localhost-unicast.md
Last active August 29, 2015 13:57
Three-node tribe using localhost/unicast.

Three-node dev tribe on a single host

Setup

drewr1

% bin/elasticsearch \
    -Des.cluster.name=drewr1 \
    -Des.network.host=127.0.0.1 \

-Des.discovery.zen.ping.unicast.hosts=127.0.0.1 \

@drewr
drewr / run-centos.sh
Created December 10, 2013 05:25
Run Elasticsearch foregrounded on CentOS without any external daemontools or runit bins.
#!/bin/sh
ulimit -l unlimited
ulimit -n unlimited
CLUSTER=amex
NODE=node01
export ES_HEAP_SIZE=24g
#!/bin/sh
curl -XDELETE localhost:9200/foo >/dev/null
curl -XPUT localhost:9200/foo/t/1\?routing=one -d'{"fizzle":[1,2]}'; echo
curl -XPUT localhost:9200/foo/t/2\?routing=two -d'{"fazzle":[3223,23]}'; echo
curl -XPOST localhost:9200/foo/_refresh; echo
curl localhost:9200/foo/_search -d'
@drewr
drewr / results.txt
Last active December 28, 2015 10:59
Jepsen on ES
Run will take 10 seconds
0 :ok 208 ▌
1 :ok 224 ▌
2 :ok 108 ▎
3 :ok 98 ▎
4 :ok 96 ▎
5 :ok 62 ▏
6 :ok 62 ▏
7 :ok 45 ▏
8 :ok 45 ▏
while true; do
curl https://play.google.com/store/devices -L -s --compressed \
| fgrep -q -o "Nexus 5" && say -v Fred Nexus 5 launched\!
sleep 60
done
@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
@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 / 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
#!/bin/bash
curl -XDELETE localhost:9200/test >/dev/null
curl -XPUT localhost:9200/test -d'
{
"number_of_replicas": 0,
"number_of_shards": 1
}