Last active
August 29, 2015 14:01
-
-
Save schmichael/5c3ff512359262970d16 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
set -o nounset | |
set -o errexit | |
echo "This script demonstrates inconsistencies between scan scrolls and scrolls with the default search type" | |
echo | |
echo "-- Create a test index and some documents" | |
curl -s -XPUT "http://localhost:9200/testindex" > /dev/null | |
curl -s -XPUT "http://localhost:9200/testindex/t/1" -d' | |
{ | |
"f": "foo1" | |
}' > /dev/null | |
curl -s -XPUT "http://localhost:9200/testindex/t/2" -d' | |
{ | |
"f": "foo2" | |
}' > /dev/null | |
curl -s -XPUT "http://localhost:9200/testindex/t/3" -d' | |
{ | |
"f": "foo3" | |
}' > /dev/null | |
echo "-- search_type=scan returns 0 results" | |
SID=$(curl -s -XGET "http://localhost:9200/testindex/_search?scroll=5m&size=1&search_type=scan" | jq -r ._scroll_id) | |
echo "-- Returns all 3 documents!" | |
curl -s -XGET "http://localhost:9200/_search/scroll?scroll_id=$SID&size=1" | jq '.hits.hits | length' | |
echo "-- Searching without the scan type returns values *and* honors size=1" | |
curl -s -XGET "http://localhost:9200/testindex/_search?scroll=5m&size=1" | jq '.hits.hits | length' | |
SID=$(curl -s -XGET "http://localhost:9200/testindex/_search?scroll=5m&size=1" | jq -r ._scroll_id) | |
echo "-- Scrolling remembers the size" | |
curl -s -XGET "http://localhost:9200/_search/scroll?scroll_id=$SID" | jq '.hits.hits | length' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment