|
| 1 | +================================================== |
| 2 | +MongoDB Namespace Mapping Configuration Properties |
| 3 | +================================================== |
| 4 | + |
| 5 | +.. default-domain:: mongodb |
| 6 | + |
| 7 | +.. contents:: On this page |
| 8 | + :local: |
| 9 | + :backlinks: none |
| 10 | + :depth: 2 |
| 11 | + :class: singlecol |
| 12 | + |
| 13 | +Overview |
| 14 | +-------- |
| 15 | + |
| 16 | +Use the following configuration settings to specify which MongoDB database |
| 17 | +and collection that your sink connector writes data to. You can use the |
| 18 | +default ``DefaultNamespaceMapper`` or specify a custom class. |
| 19 | + |
| 20 | +For a list of categories of sink connector configuration settings, see the |
| 21 | +guide on :doc:`Sink Connector Configuration Properties </sink-connector/configuration-properties>`. |
| 22 | + |
| 23 | +Settings |
| 24 | +-------- |
| 25 | + |
| 26 | +.. list-table:: |
| 27 | + :header-rows: 1 |
| 28 | + :widths: 25 75 |
| 29 | + |
| 30 | + * - Name |
| 31 | + - Description |
| 32 | + |
| 33 | + * - | **namespace.mapper** |
| 34 | + - | **Type:** string |
| 35 | + | |
| 36 | + | **Description:** |
| 37 | + | The fully-qualified class name of the class that specifies which |
| 38 | + database or collection in which to sink the data. The default |
| 39 | + ``DefaultNamespaceMapper`` uses values specified in the |
| 40 | + ``database`` and ``collection`` properties. |
| 41 | + |
| 42 | + .. seealso:: |
| 43 | + |
| 44 | + The connector includes an alternative class for specifying the |
| 45 | + database and collection called ``FieldPathNamespaceMapper``. See |
| 46 | + the :ref:`FieldPathNamespaceMapper settings <fieldpathnamespacemapper-settings>` |
| 47 | + for more information. |
| 48 | + |
| 49 | + | **Default**: |
| 50 | + |
| 51 | + .. code-block:: none |
| 52 | + |
| 53 | + com.mongodb.kafka.connect.sink.namespace.mapping.DefaultNamespaceMapper |
| 54 | + | **Accepted Values**: A fully qualified Java class name of a class that implements the ``NamespaceMapper`` interface. |
| 55 | + |
| 56 | + * - **database** |
| 57 | + - | *Required* |
| 58 | + | |
| 59 | + | **Type:** string |
| 60 | + | |
| 61 | + | **Description:** |
| 62 | + | The name of the MongoDB database to which the sink connector writes. |
| 63 | + | |
| 64 | + | **Accepted Values**: A MongoDB database name |
| 65 | + |
| 66 | + * - **collection** |
| 67 | + - | *Required* |
| 68 | + | |
| 69 | + | **Type:** string |
| 70 | + | |
| 71 | + | **Description:** |
| 72 | + | The name of the MongoDB collection to which the sink connector |
| 73 | + writes. If your sink connector follows multiple topics, this |
| 74 | + is the default collection for any writes that are not otherwise |
| 75 | + specified. |
| 76 | + | |
| 77 | + | **Accepted Values**: A MongoDB collection name |
| 78 | + |
| 79 | +.. _fieldpathnamespacemapper-settings: |
| 80 | + |
| 81 | +FieldPathNamespaceMapper Settings |
| 82 | +--------------------------------- |
| 83 | + |
| 84 | +If you configure your sink connector to use the ``FieldPathNamespaceMapper``, |
| 85 | +you can specify which database and collection to sink a document based on the |
| 86 | +data's field values. |
| 87 | + |
| 88 | +To enable this mapping behavior, set your sink connector ``namespace.mapper`` |
| 89 | +configuration property to the fully-qualified class name as shown below: |
| 90 | + |
| 91 | +.. code-block:: properties |
| 92 | + |
| 93 | + namespace.mapper=com.mongodb.kafka.connect.sink.topic.mapping.FieldPathNamespaceMapper |
| 94 | + |
| 95 | +The ``FieldPathNamespaceMapper`` requires you to specify the following |
| 96 | +settings: |
| 97 | + |
| 98 | +- One or both mapping properties to a database and collection |
| 99 | +- One of the ``key`` or ``value`` mappings to a database |
| 100 | +- One of the ``key`` or ``value`` mappings to a collection |
| 101 | + |
| 102 | +You can use the following settings to customize the behavior of the |
| 103 | +``FieldPathNamespaceMapper``: |
| 104 | + |
| 105 | +.. list-table:: |
| 106 | + :header-rows: 1 |
| 107 | + :widths: 40 60 |
| 108 | + |
| 109 | + * - Name |
| 110 | + - Description |
| 111 | + |
| 112 | + * - | **namespace.mapper.key.database.field** |
| 113 | + - | **Type:** string |
| 114 | + | |
| 115 | + | **Description:** |
| 116 | + | The name of the key document field that specifies the name of the |
| 117 | + database in which to write. |
| 118 | + |
| 119 | + * - | **namespace.mapper.key.collection.field** |
| 120 | + - | **Type:** string |
| 121 | + | |
| 122 | + | **Description:** |
| 123 | + | The name of the key document field that specifies the name of the |
| 124 | + collection in which to write. |
| 125 | + |
| 126 | + * - | **namespace.mapper.value.database.field** |
| 127 | + - | **Type:** string |
| 128 | + | |
| 129 | + | **Description:** |
| 130 | + | The name of the value document field that specifies the name of the |
| 131 | + database in which to write. |
| 132 | + |
| 133 | + * - | **namespace.mapper.value.collection.field** |
| 134 | + - | **Type:** string |
| 135 | + | |
| 136 | + | **Description:** |
| 137 | + | The name of the value document field that specifies the name of the |
| 138 | + collection in which to write. |
| 139 | + |
| 140 | + * - | **namespace.mapper.error.if.invalid** |
| 141 | + - | **Type:** boolean |
| 142 | + | |
| 143 | + | **Description:** |
| 144 | + | Whether to throw an exception when either the document is missing the |
| 145 | + mapped field or it has an invalid BSON type. |
| 146 | + | When set to ``true``, the connector does not process documents |
| 147 | + missing the mapped field or that contain an invalid BSON type. |
| 148 | + The connector may halt or skip processing depending on the related |
| 149 | + error-handling configuration settings. |
| 150 | + | When set to ``false``, if a document is missing the mapped field or |
| 151 | + if it has an invalid BSON type, the connector defaults to |
| 152 | + writing to the specified ``database`` and ``collection`` settings. |
| 153 | + | |
| 154 | + | **Default**: ``false`` |
| 155 | + | **Accepted Values**: ``true`` or ``false`` |
| 156 | + |
0 commit comments