Skip to content

Instantly share code, notes, and snippets.

@thmttch
Created February 21, 2012 13:31
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 thmttch/1876593 to your computer and use it in GitHub Desktop.
Save thmttch/1876593 to your computer and use it in GitHub Desktop.
ES 0.19.0.RC3: Where's my _size? :(
#!/usr/bin/env bash
h=localhost:9200
g='curl -XGET '
p='curl -XPOST '
u='curl -XPUT '
d='curl -XDELETE '
# make the index
$u "$h/hello"
# make the mapping, and check
$u "$h/hello/type1/_mapping" -d '{
"msg": {
"properties": {
"body": {
"type": "string",
"store": "yes"
}
},
"_size": {
"enabled": true,
"store": "yes"
}
}
}'
$g "$h/hello/type1/_mapping?pretty=true"
# add some docs
$p "$h/hello/type1/1" -d '{
"msg": "short"
}'
$p "$h/hello/type1/2" -d '{
"msg": "longer"
}'
$p "$h/hello/type1/3" -d '{
"msg": "really longer"
}'
# force a refresh, just in case
$p "$h/hello"
sleep 3
echo ''
echo ''
echo ''
# where's my _size? :(
$g "$h/hello/type1/1?pretty=true"
#{
# "_index" : "hello",
# "_type" : "type1",
# "_id" : "1",
# "_version" : 1,
# "exists" : true, "_source" : {
# "msg": "short"
#}
#}
$g "$h/hello/type1/1?pretty=true&fields=_size"
#{
# "_index" : "hello",
# "_type" : "type1",
# "_id" : "1",
# "_version" : 1,
# "exists" : true
#}
$g "$h/hello/type1/1?fields=_size"
#{"_index":"hello","_type":"type1","_id":"1","_version":1,"exists":true}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment