Skip to content

Instantly share code, notes, and snippets.

@tikitu
Last active December 30, 2015 03:59
Show Gist options
  • Save tikitu/7773227 to your computer and use it in GitHub Desktop.
Save tikitu/7773227 to your computer and use it in GitHub Desktop.
ElasticSearch: bug in output format of field of type "byte" when using ?fields= with document get.
curl -XPOST "http://localhost:9200/my_index/my_type/_mapping" -d'
{
"my_type": {
"properties": {
"byte_field": {"type": "byte"},
"int_field": {"type": "integer"},
"long_field": {"type": "long"}
}
}
}'
curl -XPOST "http://localhost:9200/my_index/my_type/1" -d'
{"byte_field":3, "int_field":4, "long_field":5}'
curl -XGET "http://localhost:9200/my_index/my_type/1?pretty=true"
# Returns:
#{
# "_index": "my_index",
# "_type": "my_type",
# "_id": "1",
# "_version": 1,
# "exists": true,
# "_source": {
# "byte_field": 3,
# "int_field": 4,
# "long_field": 5
# }
#}
curl -XGET "http://localhost:9200/my_index/my_type/1?fields=byte_field,int_field,long_field&pretty=true"
# Returns:
#{
# "_index": "my_index",
# "_type": "my_type",
# "_id": "1",
# "_version": 1,
# "exists": true,
# "fields": {
# "int_field": 4,
# "long_field": 5,
# "byte_field": "3"
# }
#}
@tikitu
Copy link
Author

tikitu commented Dec 3, 2013

The issue is the string value of "byte_field" in the last request.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment