I have a situation in which the documents being indexed occasionally have
fields with different types. I don't control the documents being indexed
and sometimes they will have field that, when first seen, is a number type,
but in later documents may be a string type.
I've tried to create a dynamic_mapping to treat everything as a string, but
it doesn't appear to be working for me.
The following sequence will fail (note the "test" field changes type):
curl -XDELETE "http://localhost:9200/test/"
curl -XPUT "http://localhost:9200/test/"
curl -XPUT http://localhost:9200/test/test/_mapping -d '
{
"test": {
"dynamic_templates": [
{
"all_fields": {
"match": "*",
"match_mapping_type" : ["string", "integer", "long", "float",
"double", "boolean"],
"mapping": {
"type": "string"
}
}
}
],
"properties": {
"meta": {
"type": "object",
"properties": {
"timestamp": {
"store": "yes",
"type": "date"
},
"foo": {
"type": "object",
"properties": {
"bar": {
"index": "not_analyzed",
"type": "string"
}
}
}
}
}
}
}
}'
curl -XPUT http://localhost:9200/test/test/1 -d '
{
"meta": [{
"timestamp": 1234567890,
"test": 123,
"foo": {
"bar" : "Hello World"
},
"fruits" : {
"canned": {
"orchard" : ["Apples", "Oranges", "Peaches"]
}
}
}]
}'
curl -XPUT http://localhost:9200/test/test/1 -d '
{
"meta": [{
"timestamp": 1234567890,
"test": "abc",
"foo": {
"bar" : "Hello World"
},
"fruits" : {
"canned": {
"orchard" : ["Apples", "Oranges", "Peaches"]
}
}
}]
}'
The error reported is:
{
"error": "MapperParsingException[Failed to parse [meta.test]]; nested:
NumberFormatException[For input string: "abc"]; ",
"status": 400
}
Anyone know how I create a mapping to deal with this case?
Thanks.
--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.