Skip to content

Instantly share code, notes, and snippets.

@nik9000
Created February 11, 2014 15:35
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 nik9000/8937202 to your computer and use it in GitHub Desktop.
Save nik9000/8937202 to your computer and use it in GitHub Desktop.
#!/bin/bash
curl -s -XDELETE "http://localhost:9200/test?pretty" | tee /tmp/check_script_speed.log
curl -s -XPOST "http://localhost:9200/test?pretty" | tee -a /tmp/check_script_speed.log
curl -s -XPUT http://localhost:9200/test/test/_mapping?pretty -d'{
"test" : {
"properties": {
"i" : {
"type": "integer"
}
}
}
}' | tee -a /tmp/check_script_speed.log
echo -n "Indexing" | tee -a /tmp/check_script_speed.log
for j in {1..1000}; do
rm /tmp/check_script_speed_bulk.txt
for i in {1..1000}; do
echo '{ "index" : { "_index" : "test", "_type" : "test" } }' >> /tmp/check_script_speed_bulk.txt
if [ "$j" -lt 5 ]; then
echo '{"i": '$i'}' >> /tmp/check_script_speed_bulk.txt
else
echo '{"nothing": "some text"}' >> /tmp/check_script_speed_bulk.txt
fi
done
curl -s -XPOST "http://localhost:9200/_bulk?pretty" --data-binary @/tmp/check_script_speed_bulk.txt >> \
/tmp/check_script_speed.log
echo -n '.'
done
echo 'Done'
curl -s -XPOST http://localhost:9200/test/_refresh?pretty | tee -a /tmp/check_script_speed.log
# Ignore first execution's time because it includes cache population and script compilation
curl -s http://localhost:9200/test/_search?pretty -d '{
"size": 1,
"query": {
"function_score": {
"functions": [
{
"script_score": {
"script": '"\"log10((doc['i'].isEmpty() ? 0 : doc['i'].value) + 2)\""'
}
}
]
}
}
}' | tee -a /tmp/check_script_speed.log
curl -s http://localhost:9200/test/_search?pretty -d '{
"size": 1,
"query": {
"function_score": {
"functions": [
{
"script_score": {
"script": '"\"log10((doc['i'].empty ? 0 : doc['i'].value) + 2)\""'
}
}
]
}
}
}' | tee -a /tmp/check_script_speed.log
time curl -s http://localhost:9200/test/_search?pretty -d '{
"size": 1,
"query": {
"function_score": {
"functions": [
{
"script_score": {
"script": '"\"log10((doc['i'].isEmpty() ? 0 : doc['i'].value) + 2)\""'
}
}
]
}
}
}' 2>&1 | tee -a /tmp/check_script_speed.log
time curl -s http://localhost:9200/test/_search?pretty -d '{
"size": 1,
"query": {
"function_score": {
"functions": [
{
"script_score": {
"script": '"\"log10((doc['i'].empty ? 0 : doc['i'].value) + 2)\""'
}
}
]
}
}
}' 2>&1 | tee -a /tmp/check_script_speed.log
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment