I am trying to create a dynamic mapping for the following objects:
{ "product": { "productId": 99999, "manufacturerId": "A0001", "manufacturerCode": "A101LI", "name": "Test Product", "description": "Describe the product here.", "feature_details":{ "category": "Category1", "brand": "Brand Name" }, "feature_tpcerts":{ "certifiedPass": true, "levelCertified": 2 }, "feature_characteristics":{ "amount": 0.73, "location": 49464 } } }
I would like feature_* properties to be a nested type, which I defined in the nested_feature pattern matching below and that works as expected. However, I also want each property of the embedded object of the feature_* property to be multi_value with the optional facet property. I tried the second nested_template template, but without any success.
{ "product" : { "_timestamp" : {"enabled" : true, "store": "yes" }, "dynamic_templates": [ { "nested_feature": { "match" : "feature_*", "mapping" : { "type" : "nested", "stored": "true" } } }, { "nested_template": { "match": "feature_*.*", "mapping": { "type": "multi_field", "fields": { "{name}": { "type": "{dynamic_type}", "index": "analyzed" }, "facet": { "type": "{dynamic_type}", "index": "not_analyzed" } } } } } ], "properties" : { "productId" : { "type" : "integer", "store" : "yes"}, "manufacturerId" : { "type" : "string", "store" : "yes", "index" : "analyzed"}, "manufacturer" : { "type" : "string", "store" : "yes", "index" : "not_analyzed"}, "manufacturerCode" : { "type" : "string", "store" : "yes"}, "name" : {"type" : "string", "store" : "yes"}, "description": {"type": "string", "index" : "analyzed"} } } }
Unfortunately, the properties in feature_* properties are created from another process and can be almost any pair of names / values. Any suggestions on using a dynamic template to set a property of both a nested and for each property inside a multi_field nested object with the additional facet property?