I'd suggest that you use a more flexible mapping.
Using may be a data structure like:
DELETE test
PUT test
{
"mappings": {
"properties": {
"name": {
"type": "text"
},
"bvid": {
"type": "keyword"
},
"gtin": {
"type": "keyword"
},
"manufacturerCode": {
"type": "keyword"
},
"productState": {
"properties": {
"imageReady": {
"type": "keyword",
"index": false
},
"contentReady": {
"type": "keyword",
"index": false
},
"reviewReady": {
"type": "keyword",
"index": false
}
}
},
"physicalStatus": {
"properties": {
"status": {
"type": "keyword",
"index": false
}
}
},
"images": {
"properties": {
"url": {
"type": "keyword",
"index": false
},
"thumbnailUrl": {
"type": "keyword",
"index": false
},
"imageType": {
"type": "keyword",
"index": false
},
"isHero": {
"type": "boolean",
"index": false
}
}
},
"data": {
"type": "nested",
"properties": {
"name": {
"type": "keyword"
},
"value": {
"type": "text"
}
}
}
}
}
}
POST test/_doc
{
"name": "Good Goodies",
"bvid": "c7befa56",
"gtin": "8964002148134",
"manufacturerCode": "209975",
"images": [
{
"url": "https://storage.googleapis.com/",
"thumbnailUrl": "https://storage.googleapis.com/",
"isHero": true,
"imageType": "hero"
}
],
"productState": {
"contentReady": "Complete",
"imageReady": "Complete",
"reviewReady": "None"
},
"physicalStatus": {
"status": "Cleared"
},
"data": [
{ "name": "In Package Depth", "value": "145" },
{ "name": "Sodium Per Nutrient Basis Quantity", "value": "135.0mg" },
{ "name": "Packaging Type", "value": "Box" },
{ "name": "Level of Fat Claim", "value": "UNIDENTIFIED" },
{ "name": "Nutrient Basis Quantity", "value": "100g" },
{ "name": "Protein Per Nutrient Basis Quantity", "value": "5.0g" },
{ "name": "Type of Cake", "value": "UNIDENTIFIED" },
{ "name": "Packaging Shape", "value": "Rectangular" },
{ "name": "Sugars Per Nutrient Basis Quantity", "value": "31.9g" },
{ "name": "Packaging Recycling Process Type", "value": "Recyclable" },
{ "name": "GPC Category Code", "value": "10000172" },
{ "name": "Fibre Per Nutrient Basis Quantity", "value": "0.4g" },
{ "name": "Consumer Usage Instructions", "value": "Store in room temperature." },
{ "name": "Net Weight", "value": "252" },
{ "name": "Ingredient Statement", "value": "Wheat Flour,Sugar, Vegetable Oil,Invert Syrup, Fresh Eggs, Skimmed Milk Powder, Cocoa Powder, Salt, Baking Powder, Emulsifier, Potassium Sorbate, Citric Acid, Glycerin, Sorbitol, Vanillin Powder, Corn Starch, Food Preservatives, Xanthan Gum, Nature Identical Flavor and Permitted Food Color." },
{ "name": "Fat Per Nutrient Basis Quantity", "value": "17.9g" },
{ "name": "In Package Height", "value": "70" },
{ "name": "Nutrient Basis Quantity Type Code", "value": "By Serving" },
{ "name": "Product Range", "value": "Cake" },
{ "name": "Saturated Fat Per Nutrient Basis Quantity", "value": "0.4g" },
{ "name": "Special Occasion Claim", "value": "NO" },
{ "name": "Product Description", "value": "Enjoy the three in one baked freshness of sweet fillings, great taste & nutrition." },
{ "name": "Gluten Free Claim", "value": "NO" },
{ "name": "Functional Name", "value": "Good Goodies Merry Berry" },
{ "name": "Product Form Description", "value": "Box" },
{ "name": "Packaging Feature", "value": "Wrap" },
{ "name": "Family", "value": "Bread/Bakery Products" },
{ "name": "Gross Weight", "value": "300" },
{ "name": "Energy from Fat Per Nutrient Basis Quantity", "value": "399Cal" },
{ "name": "Price Value", "value": "108" },
{ "name": "In Package Width", "value": "180" },
{ "name": "GTIN", "value": "8964002148134" },
{ "name": "Nutrient Measurement Precision", "value": "Approximately" },
{ "name": "Product Name", "value": "Good Goodies Triple Strawberry Jam Filled Merry Berry 6 Long Cakes" },
{ "name": "If Organic", "value": "NO" },
{ "name": "Cholesterol Per Nutrient Basis Quantity", "value": "60.0mg" },
{ "name": "Brand Name", "value": "Good Goodies" },
{ "name": "Carbohydrates Per Nutrient Basis Quantity", "value": "54.5g" },
{ "name": "Variant Description", "value": "Merry Berry" },
{ "name": "Class", "value": "Sweet Bakery Products" },
{ "name": "If Coated", "value": "YES" },
{ "name": "Packaging Function", "value": "Protected" },
{ "name": "Ingredient of Concern", "value": "Contains Wheat, Eggs & Milk." },
{ "name": "GPC Category Description", "value": "Cakes - Sweet (Shelf Stable)" },
{ "name": "Brick", "value": "Cakes - Sweet (Shelf Stable)" },
{ "name": "Segment", "value": "Food/Beverage/Tobacco" },
{ "name": "If Part Baked", "value": "YES" },
{ "name": "Regulated Product Name", "value": "Good Goodies Triple Strawberry Jam Filled Merry Berry" },
{ "name": "Form of Cake", "value": "UNCLASSIFIED" },
{ "name": "Packaging Material Type", "value": "Paper Paperboard" },
{ "name": "Sub Brand", "value": "NotApplicable" },
{ "name": "Brand", "value": "Good Goodies" },
{ "name": "Brand Owner", "value": "NoOwner" }
]
}
This is much more flexible and is keeping the mapping as minimal as possible.
It comes with more complex queries though as you need to deal with nested objects. See