If I configure a field to be a certain type, for example, an integer, I'm not sure why I can then save a string value to that field? I expect code like this to throw an error:
curl -XPUT 'localhost:9200/my_index?pretty' -H 'Content-Type: application/json' -d'
{
"mappings" : {
"my_type": {
"properties": {
"keyword_field" : {
"type": "keyword"
},
"integer_field": {
"type": "integer"
}
}
}
}
}
'
curl -XPUT 'localhost:9200/my_index/my_type/1?pretty' -H 'Content-Type: application/json' -d'
{
"keyword_field": false,
"integer_field": "10"
}
'
curl -XPUT 'localhost:9200/my_index/my_type/1?pretty' -H 'Content-Type: application/json' -d'
{
"keyword_field": "text",
"integer_field": 11
}
'
I thought Elasticsearch might be doing a data conversion on the integer field, but after looking at the saved document it looks like Elasticsearch is saving the string "10"...which would mean numeric comparisons with that field would fail in the future. Not sure what's going on with saving json false to a keyword field.
Thanks,
Troy