Skip to content

Instantly share code, notes, and snippets.

@alissonsales
Created November 27, 2017 22:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save alissonsales/77f5a50214ccd71b26a86956b6230c07 to your computer and use it in GitHub Desktop.
Save alissonsales/77f5a50214ccd71b26a86956b6230c07 to your computer and use it in GitHub Desktop.
Test ES sliced scroll
n_shards=$1
echo "ES version"
curl -s localhost:9200
echo "Create index"
curl -si -H 'Content-type: application/json' -X PUT localhost:9200/twitter -d '
{
"settings": {
"index": {
"number_of_shards": '$n_shards',
"number_of_replicas": 0
}
},
"mappings": {
"tweet": {
"_routing": { "required": true },
"properties": {
"title": { "type": "text" }
}
}
}
}
'
echo "Adding docs..."
for i in `seq 1 9`
do
curl -si -H 'Content-type: application/json' \
-X PUT 'localhost:9200/twitter/tweet/t'$i'?routing=key&refresh=true' \
-d '{ "title": "tweet '$i'" }' > /dev/null
done
echo "slice id 0 search"
curl -s 'localhost:9200/twitter/tweet/_search?scroll=1m&sort=_doc&routing=key&_source=false' -d '
{
"slice": { "id": 0, "max": 2 },
"query": { "match_all": { } }
}
' | jq '.hits.total'
echo "slice id 1 search"
curl -s 'localhost:9200/twitter/tweet/_search?scroll=1m&sort=_doc&routing=key&_source=false' -d '
{
"slice": { "id": 1, "max": 2 },
"query": { "match_all": { } }
}
' | jq '.hits.total'
echo ""
curl -si -X DELETE localhost:9200/twitter > /dev/null
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment