# Trouble defining the dynamic mapping for the structured json document

**URL:** <https://discuss.elastic.co/t/trouble-defining-the-dynamic-mapping-for-the-structured-json-document/202384>\
**Category:** Elasticsearch\
**Created:** [October 4, 2019, 7:59pm UTC](https://discuss.elastic.co/t/trouble-defining-the-dynamic-mapping-for-the-structured-json-document/202384 "2019-10-04T19:59:47Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Balu\_P](https://avatars.discourse-cdn.com/v4/letter/b/3ec8ea/32.png) [@Balu\_P](https://discuss.elastic.co/u/Balu_P)\
**Post date:** [October 4, 2019, 7:59pm UTC](https://discuss.elastic.co/t/trouble-defining-the-dynamic-mapping-for-the-structured-json-document/202384/1 "2019-10-04T19:59:47Z")

</div>

```
this is my mapping file defined 

{
  "dynamic": false,
  "dynamic_templates": [
    {
      "product_core_attributes": {
        "path_match": "product_attributes.*.values",
        "path_unmatch": "product_attributes.*description.values",
        "match_mapping_type": "object",
        "mapping": {
          "type": "object",
          "properties": {
            "value": {
              "type": "text"
            }
          }
        }
      }
    }
  ],
  "properties": {
    "product_id": {
      "type": "keyword"
    },
    "product_version": {
      "type": "long"
    },
    "status": {
      "type": "keyword"
    },
    "created_at": {
      "type": "date",
      "format": "epoch_millis"
    },
    "updated_at": {
      "type": "date",
      "format": "epoch_millis"
    }
  }
}

and the sample document looks like this
{
  "request_id": "req1",
  "product_id": "1LRNJPE6LKLD",
  "type": "PRODUCT",
  "product_version": 1570042161414,
  "abstract_product_id": "2SV5VK7CSNYW",
  "product_attributes": {
    "a1": {
      "properties": {
        "added": "Thu Nov 09 11:52:08 UTC 2017",
        "attributeName": "a1",
        "content_lifecycle_status": "ACTIVE",
        "display_attribute_name": "color",
        "fromPcp": "false",
        "isFacet": "true",
        "isVariant": "true",
        "source": "mp"
      },
      "values": [
        {
          "isPrimary": "false",
          "isVariant": "true",
          "locale": "en_US",
          "source_key": "color",
          "source_value": "Black",
          "value": "Black"
        },
        {
          "isFacetValue": "true",
          "locale": "en_US",
          "value": "Black"
        }
      ]
    },
    "a2": {
      "properties": {
        "added": "Thu Nov 09 11:52:08 UTC 2017",
        "attributeName": "a2",
        "content_lifecycle_status": "ACTIVE",
        "display_attribute_name": "color",
        "fromPcp": "false",
        "isFacet": "true",
        "isVariant": "true",
        "source": "mp"
      },
      "values": [
        {
          "display_attr_name": "Brand",
          "isPrimary": "true",
          "locale": "en_US",
          "source_key": "brand",
          "source_value": "LESHP",
          "value": "LESHP"
        },
        {
          "facet_version": "1.1",
          "isFacetValue": "true",
          "locale": "en_US",
          "value": "LESHP"
        }
      ]
    }
  },
  "status": "PROCESSED",
  "created_at": 1510228329689,
  "updated_at": 1570042161414
}

I want to dynamically detect product_attributes.*.values and index only the "value" for all the attributes

Please suggest
```

---

<div class="post-metadata">

**Author:** ![spinscale](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/spinscale/32/25011_2.png) [@spinscale](https://discuss.elastic.co/u/spinscale)\
**Post date:** [October 7, 2019, 12:54pm UTC](https://discuss.elastic.co/t/trouble-defining-the-dynamic-mapping-for-the-structured-json-document/202384/2 "2019-10-07T12:54:16Z")

</div>

hey,

take a look at [dynamic templates](https://www.elastic.co/guide/en/elasticsearch/reference/7.4/dynamic-templates.html). You could configure any field not to be indexed with the exception of the value field.

--Alex

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [November 4, 2019, 12:54pm UTC](https://discuss.elastic.co/t/trouble-defining-the-dynamic-mapping-for-the-structured-json-document/202384/3 "2019-11-04T12:54:25Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
