Skip to content

Instantly share code, notes, and snippets.

@erickt
Created December 16, 2011 21:30
Show Gist options
  • Select an option

  • Save erickt/1488080 to your computer and use it in GitHub Desktop.

Select an option

Save erickt/1488080 to your computer and use it in GitHub Desktop.
#!/bin/sh
set -e
URL="http://localhost:9200"
function run() {
echo "%" "$@"
"$@"
echo
echo
}
run curl -XDELETE "$URL/test/"
run curl -XDELETE "$URL/_percolator"
run curl -XPUT "$URL/test/" -d '
{
"index": {},
"settings": {
"analysis": {
"analyzer": {
"dash_path": { "type": "custom", "tokenizer": "dash_path" }
},
"tokenizer": {
"dash_path": { "type": "path_hierarchy", "delimiter": "-" }
}
}
},
"mappings": {
"test": {
"properties": {
"location": { "type":"string", "analyzer": "dash_path" }
}
}
}
}'
run curl -XGET "$URL/test/_mapping"
run curl -XGET "$URL/test/_analyze?field=test.location&pretty=true" -d "A-A-A"
run curl -XPOST "$URL/test/test/?refresh=true" -d '{"location":"A-A-A"}'
run curl -XPOST "$URL/test/test/?refresh=true" -d '{"location":"A-A-B"}'
run curl -XPOST "$URL/test/test/?refresh=true" -d '{"location":"A-B-A"}'
run curl -XPOST "$URL/test/test/?refresh=true" -d '{"location":"A-B-B"}'
run curl -XPOST "$URL/test/test/?refresh=true" -d '{"location":"B-A-A"}'
run curl -XPOST "$URL/test/test/?refresh=true" -d '{"location":"B-A-B"}'
run curl -XPOST "$URL/test/test/?refresh=true" -d '{"location":"B-B-A"}'
run curl -XPOST "$URL/test/test/?refresh=true" -d '{"location":"B-B-B"}'
run curl -XGET "$URL/test/test/_search?pretty=true" -d '
{
"query": {
"query_string": {
"query": "location:A-B",
"analyzer": "keyword"
}
}
}'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment