You can let ES generate the mappings for you with the help of dynamic template path matching:
PUT myindex
{
"mappings": {
"dynamic_templates": [
{
"catch_daily_statistics": {
"path_match": "daily_statistics.*",
"mapping": {
"type": "object",
"properties": {
"sold_count": {
"type": "long"
}
}
}
}
}
]
}
}
But before you proceed with this architectural choice, I'd recommend to first check this answer which deals with the difficulties of aggregating on dicts-of-dicts.
It'd be more reasonable to use daily indices as @Evaldas pointed out. But I'd go with nested
fields of the form:
POST myindex/_doc
{
"name": "bmw",
"daily_stats": [
{
"day_date": "2021/01/01",
"day_iso_num": 1,
"sold_count": 5
},
{ ... }
]
}
That way, you'll be able to perform
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…