Hello guys,
I'm trying to learn Elasticsearh and I'm getting confused with Array data types.
I have define 2 text type fields and I have put some test data in to the index. To my surprise, the index accept combination of text and numeric.
I'm getting confuse to understand this (https://www.elastic.co/guide/en/elasticsearch/reference/6.5/array.html)
Am I misunderstand something here ?
Here is my index mapping
{
"david_idx" : {
"mappings" : {
"_doc" : {
"properties" : {
"fav" : {
"type" : "text"
},
"name" : {
"type" : "text"
}
}
}
}
}
}
And it seems like 'fav' can hold more than just text.
I have insert it as single text
{
"_index" : "david_idx",
"_type" : "_doc",
"_id" : "zWNZy2gBOusqcldvSZ8J",
"_score" : 1.0,
"_source" : {
"name" : "first test",
"fav" : "apple"
}
},
and Array
{
"_index" : "david_idx",
"_type" : "_doc",
"_id" : "I2Nay2gBOusqcldvlKED",
"_score" : 1.0,
"_source" : {
"name" : "second test",
"fav" : [
"apple",
"orange"
]
}
},
a numeric field
{
"_index" : "david_idx",
"_type" : "_doc",
"_id" : "JXH-2WgBOusqcldvzl8j",
"_score" : 1.0,
"_source" : {
"name" : "fifth test",
"fav" : 1
}
},
even array of nummeric
{
"_index" : "david_idx",
"_type" : "_doc",
"_id" : "vXH_2WgBOusqcldvTl8R",
"_score" : 1.0,
"_source" : {
"name" : "sixth test - number test",
"fav" : [
99,
98,
97
]
}
},
and mixture of text andm numeric.
{
"_index" : "david_idx",
"_type" : "_doc",
"_id" : "LHEL2mgBOusqcldvEmu1",
"_score" : 1.0,
"_source" : {
"name" : "seventh test",
"fav" : [
5,
"banana"
]
}
}