Skip to content

Instantly share code, notes, and snippets.

@mal
Created July 30, 2014 10:04
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 mal/68bd3479e30258d833e2 to your computer and use it in GitHub Desktop.
Save mal/68bd3479e30258d833e2 to your computer and use it in GitHub Desktop.
SERVER=localhost:9200
REQUEST() {
curl -sS -X$1 "http://$SERVER$2" -d "$3"
echo
}
GET() {
REQUEST GET "$1"
}
POST() {
REQUEST POST "$1" "$2"
}
PUT() {
REQUEST PUT "$1" "$2"
}
DELETE() {
REQUEST DELETE "$1"
}
DELETE /t
PUT /t '
{
"settings": {
"number_of_replicas": 0,
"number_of_shards": 1
},
"mappings": {
"t": {
"properties": {
"vals": {"type": "integer"}
}
}
}
}'
PUT /t/t/1 '{ "vals": [0,2,1] }'
echo ---
sleep 1
POST /t/t/_search '
{
"script_fields": {
"minimum": {
"lang": "groovy",
"script": "lowest",
"params": {
"field": "vals"
}
}
}
}
'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment