@dadoonet I'm using GoLang client API. This one- GitHub - olivere/elastic: Deprecated: Use the official Elasticsearch client for Go at https://github.com/elastic/go-elasticsearch
My mapping for single index including multiple types: product
and category
.
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"},
},
},
},
},
"product": map[string]interface{}{
"properties": map[string]interface{}{
"activity_name": map[string]interface{}{"type": "text"},
"app_type": map[string]interface{}{"type": "text"},
},
},
},
}
When I try to bulk index the data, it creates a single index with 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"
}
}
},
"product": {
"properties": {
"activity_name": {
"type": "text"
},
"app_type": {
"type": "text"
}
}
}
}
}
}
As you can notice it is copying category
fields data outside category
root field too.
Why the fields inside properties
are being copied outside category
? How should I avoid it? How should I define custom types?