Hi, I'm trying to create my mappings have multiple types within the same index.
This is how it looks:
mappings := map[string]interface{}{
"properties": map[string]interface{}{
"category": map[string]interface{}{
"properties": map[string]interface{}{
"id": map[string]interface{}{"type": "long"},
"name": map[string]interface{}{"type": "text"},
"type": map[string]interface{}{"type": "text"},
"image_version": map[string]interface{}{
"type": "nested",
"properties": map[string]interface{}{
"image_height": map[string]interface{}{"type": "float"},
"image_width": map[string]interface{}{"type": "float"},
},
},
},
},
},
}
This is written in Golang. Consider for assume we've mappings for promotion
type too.
When I try to bulk index the data, it creates mappings like this:
{
"mappings": {
"properties": {
"category": {
"properties": {
"id": {
"type": "integer"
},
"name": {
"type": "keyword"
},
"type": {
"type": "text"
},
"image_version": {
"type": "nested",
"properties": {
"image_height": {
"type": "float"
},
"image_width": {
"type": "float"
}
}
}
}
},
"id": {
"type": "integer"
},
"name": {
"type": "keyword"
},
"type": {
"type": "text"
},
"image_version": {
"type": "nested",
"properties": {
"image_height": {
"type": "float"
},
"image_width": {
"type": "float"
}
}
},
"promotions": {
"properties": {
"activity_name": {
"type": "text"
},
"app_type": {
"type": "text"
}
}
}
}
}
}
As you can notice it is copying category
fields outside category
root field too.
Why the fields inside properties
are being copied outside category
too? How should I avoid it?
It would be great if anyone can help me with a proper solution. Thank you!