I did some more testing, and the actual reason for my problem might be this:
If I send several entries of the same kind with different types at once, the coercion fails (and a mapper_parsing_exception is thrown).
Now look at this example:
ben@ben-ubuntu14:~$curl -XPOST '192.168.56.102:9200/test/persons/' -d '{"name":"Steven", "age":"unknown"}'
{"_index":"test","_type":"persons","_id":"AVGMlpEeWllYL3SlR_qa","_version":1,"_shards":{"total":2,"successful":1,"failed":0},"created":true}
ben@ben-ubuntu14:~$ curl -XPOST '192.168.56.102:9200/test/persons/' -d '{"name":"Martin", "age":25}'
{"_index":"test","_type":"persons","_id":"AVGMltVoWllYL3SlR_qb","_version":1,"_shards":{"total":2,"successful":1,"failed":0},"created":true}
Here, the coercion seems to work.
But funnily, if I GET the entries, see what is returned:
curl -XGET http://192.168.56.102:9200/test/person/AVGMlpEeWllYL3SlR_qa?pretty
{
"_id": "AVGMlpEeWllYL3SlR_qa",
"_index": "test",
"_source": {
"age": "unknown",
"name": "Steven"
},
"_type": "person",
"_version": 1,
"found": true
}
curl -XGET http://192.168.56.102:9200/test/person/AVGMltVoWllYL3SlR_qb?pretty
{
"_id": "AVGMltVoWllYL3SlR_qb",
"_index": "test",
"_source": {
"age": 25,
"name": "Martin"
},
"_type": "person",
"_version": 1,
"found": true
}
How can 25 be an integer, when "age" is a string?:
curl -XGET http://192.168.56.102:9200/test?pretty
"test": {
"aliases": {},
"mappings": {
"person": {
"properties": {
"age": {
"type": "string"
},
"name": {
"type": "string"
}
}
}
},