I want to create dynamic mapping for objects like:
{
"id": 1,
"name": "item1",
"inventory": {
"newyork": {
"total_sales_count": 10000,
"rank": 10,
"average_sales_count": 100,
"discount": 10,
"store_info": [
{
"discounted_price": 250,
"catalog_price": 300,
"store_id": 101,
"rank": 10,
"status": "active"
},
{
"discounted_price": 150,
"catalog_price": 200,
"store_id": 102,
"rank": 11,
"status": "active"
}
],
},
"boston": {
...
"store_info": [
{
"discounted_price": 250,
"catalog_price": 300,
"store_id": 103,
"rank": 21,
"status": "active"
},
...
],
}
}
}
I would like all the objects inside store_info array to be indexed as nested so that i can query by attributes like store_id and rank. I could directly define mapping in index to treat this store_info data as nested but it is inside dynamic field which will be a city name like "newyork", "boston".
I had applied mapping to define inventory
field as nested but the same is not working.
Is there any way to achieve the same using dynamic mapping or any other method in Elasticsearch?