.. meta:: :description: This document provides usage information for the Apache Kafka SMT org.apache.kafka.connect.transforms.ValueToKey. .. _valuetokey: ========== ValueToKey ========== The following provides usage information for the |ak-tm| SMT ``org.apache.kafka.connect.transforms.ValueToKey``. Description ----------- Replace the record key with a new key formed from a subset of fields in the record value. Examples -------- These examples show how to use ``ValueToKey`` by itself and in conjunction with a second SMT. -------------------------------- Transform Fields to Message Key -------------------------------- This configuration snippet shows how to use ``ValueToKey`` to transform the ``UserId``, ``city``, and ``state`` fields into a message key. .. code-block:: json "transforms": "ValueToKey", "transforms.ValueToKey.type": "org.apache.kafka.connect.transforms.ValueToKey", "transforms.ValueToKey.fields": "userId,city,state" Before: ``{"userId": 12, "address": "1942 Wilhelm Boulevard", "city": "Topeka", "state": "KS", "country": "US"}`` After: ``{"userId": 12, "city": "Topeka", "state": "KS"}`` .. include:: includes/Example_ValueToKeyExtractField.rst Properties ---------- .. list-table:: :header-rows: 1 :widths: 15 30 10 10 10 10 * - Name - Description - Type - Default - Valid Values - Importance * - ``fields`` - Field names on the record value to extract as the record key. - list - - non-empty list - high .. include:: includes/predicate.rst