hello,
I just came across a strange behavior regarding field mappings and wanted to ask the professional, if that is really intended.
I indexed a document to a newly created index that didn't had any mappings.
Then of course due to the dynamic mappings, all relevant fields mappings where created.
In my case it was field of type text.
By accident I created new documents that had a different type for that field, in this case float.
And elasticsearch was not complaining about it.
So I did a test and also tried boolean and even an array of text.
Non of them failed.. elasticsearch just accepted whatever was coming.
I also tried a new object which luckily failed, but still.. the mapping seems a little broken to me or is this really intended ?
Btw. the other way around didn't work.. creating the initial mapping as float for instance wouldn't allow a text afterwards.
The dynamically created mapping looks like:
"mappings": {
"test": {
"properties": {
"id": {
"type": "keyword"
},
"meta": {
"properties": {
"foo": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
}
}
}
}
}
The response, when queried my index was:
hits": [
{
"_index": "test",
"_type": "test",
"_id": "3eee04e3-aaed-4a47-b013-e6a3ca408f2b",
"_score": 1.0,
"_source": {
"id": "3eee04e3-aaed-4a47-b013-e6a3ca408f2b",
"meta": {
"foo": true
}
}
},
{
"_index": "test",
"_type": "test",
"_id": "74229be1-99bf-44bf-a811-08b30e4db346",
"_score": 1.0,
"_source": {
"id": "74229be1-99bf-44bf-a811-08b30e4db346",
"meta": {
"foo": "bar"
}
}
},
{
"_index": "test",
"_type": "test",
"_id": "df68d464-f1ac-4cce-8e69-ff08f763de45",
"_score": 1.0,
"_source": {
"id": "df68d464-f1ac-4cce-8e69-ff08f763de45",
"meta": {
"foo": [
""
]
}
}
},
{
"_index": "test",
"_type": "test",
"_id": "cf837e2c-b74d-4391-9963-00f3bf689c95",
"_score": 1.0,
"_source": {
"id": "cf837e2c-b74d-4391-9963-00f3bf689c95",
"meta": {
"foo": 1.1
}
}
}
]
Interesting is also, that I can do all kinds of search operations, such as
- ?q=meta.foo:true
- ?q=meta.foo:>5
- ?q=meta.foo:[1 TO 9]
- ?q=meta.foo:bar
I've been using elasticsearch 6.0.1
Looking forward to hear from you guys.
Best regards,
Peter