Created
July 15, 2011 13:55
-
-
Save ofavre/1084738 to your computer and use it in GitHub Desktop.
ElasticSearch Scroll API (documentation) bug
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
set -v | |
curl -XDELETE 'localhost:9200/index' | |
curl -XPUT 'localhost:9200/index' -d '{"settings":{"index":{"number_of_shards":4,"number_of_replicas":0}}}' | |
curl -XPUT 'localhost:9200/index/type/_mapping' -d '{ | |
"type":{ | |
"properties":{ | |
"text":{ "type":"string", "index":"analyzed", "analyzer":"whitespace" } | |
} | |
} | |
}' | |
content="a" | |
for i in `seq 1 8`; do | |
curl -XPUT 'localhost:9200/index/type/'$i -d '{"text":"'"$content"'"}' | |
echo | |
content="$content a" | |
done | |
curl -XPOST 'localhost:9200/index/_optimize' | |
curl -XGET 'localhost:9200/index/type/_search?pretty=1' -d '{"query":{"term":{"text":"a"}}}' | |
# Using &query_type=query_and_fetch | |
out="$(curl -XGET 'localhost:9200/index/type/_search?pretty=1&search_type=query_and_fetch&scroll=1m' -d '{"size":1,"query":{"term":{"text":"a"}}}' 2>/dev/null)" | |
echo "$out" | |
scroll_id="$(echo "$out" | sed -rne 's/^.*"_scroll_id" *: *"(.*)" *, *$/\1/p')" | |
echo "$scroll_id" | |
for i in `seq 1 10`; do | |
# Result _id:5 is missing! | |
curl -XGET 'localhost:9200/_search/scroll?pretty=1&scroll=1m&scroll_id='"$scroll_id" | |
echo | |
sleep 1 | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment