Skip to content

Instantly share code, notes, and snippets.

@dminkovsky
Created February 22, 2015 16:36
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 dminkovsky/29f6efb4c3dae1a3b078 to your computer and use it in GitHub Desktop.
Save dminkovsky/29f6efb4c3dae1a3b078 to your computer and use it in GitHub Desktop.
#!/bin/bash
HOST=172.17.42.1:9200
create() {
curl -XPUT "$HOST"/test
curl -XPUT "$HOST"/test/person/_mapping?pretty -d '{
"person": {
"properties": {
"file": {
"type": "attachment",
"path": "full",
"fields": {
"file": {
"type": "string",
"term_vector":"with_positions_offsets",
"store": true
}
}
}
}
}
}'
}
post() {
curl -i -XPOST "${HOST}/test/person?refresh=true&pretty" -d'{
"file": "IkdvZCBTYXZlIHRoZSBRdWVlbiIgKGFsdGVybmF0aXZlbHkgIkdvZCBTYXZlIHRoZSBLaW5nIg=="
}'
}
count() {
curl -i "$HOST"/test/person/_count?pretty
}
show() {
curl -i "$HOST"/test/person/_search?pretty
}
search() {
curl -i -XGET "$HOST"/test/person/_search?pretty -d'{
"fields": [],
"query": {
"match": {
"file": "king queen"
}
},
"highlight": {
"fields": {
"file": {}
}
}
}'
}
delete() {
curl -i -XDELETE "$HOST"/test?pretty
}
eval $1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment