Skip to content

Instantly share code, notes, and snippets.

@kramarz
Last active August 24, 2018 09:22
Show Gist options
  • Save kramarz/20844c1cb48fc745d806dff0c0016525 to your computer and use it in GitHub Desktop.
Save kramarz/20844c1cb48fc745d806dff0c0016525 to your computer and use it in GitHub Desktop.
#!/bin/bash -ex
PORT=9222
HEADER='Content-type: application/json'
VERSION=6.4.0
[ `sysctl -n vm.max_map_count` -ge 262144 ] || sudo sysctl -w vm.max_map_count=262144
function finish {
docker rm -f test-es
}
trap finish EXIT
docker run -d -p ${PORT}:9200 --name test-es docker.elastic.co/elasticsearch/elasticsearch:${VERSION}
docker logs -f test-es | (grep -m1 "started" && pkill -P $$$$ docker) || true # wait for es to start
curl -X PUT -H "${HEADER}" "localhost:${PORT}/test?pretty" -d '
{
"settings": {
"number_of_shards": 1,
"analysis": {
"filter": { "stopwords": { "type": "stop", "stopwords": "_english_" }},
"analyzer": { "test": { "type": "custom", "tokenizer": "standard", "filter": [ "stopwords"] } }
}
}
}
'
curl -X PUT -H "${HEADER}" "localhost:${PORT}/test/_mapping/doc?pretty" -d '
{
"doc": {
"properties": {
"nested": {
"type": "nested",
"properties": {
"text_fail": {
"type":"text", "analyzer":"test"
},
"text_success": {
"type":"text", "analyzer":"standard"
}
}
}
}
}
}
'
curl -X PUT -H "${HEADER}" "localhost:${PORT}/test/doc/1/?pretty" -d '
{
"nested": {
"text_fail": "the a is an",
"text_success": "the a is an"
}
}
'
curl -X GET "localhost:${PORT}/test/doc/1/_termvectors?fields=nested.text_fail,nested.text_success&pretty"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment