Trouble defining the dynamic mapping for the structured json document

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

hey,

take a look at dynamic templates. You could configure any field not to be indexed with the exception of the value field.

--Alex

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