|
| 1 | +--- |
| 2 | +"Index documents with setting dynamic parameter to strict_allow_templates in the mapping of the index": |
| 3 | + - skip: |
| 4 | + version: " - 2.99.99" |
| 5 | + reason: "introduced in 3.0.0" |
| 6 | + |
| 7 | + - do: |
| 8 | + indices.create: |
| 9 | + index: test_1 |
| 10 | + body: |
| 11 | + mappings: |
| 12 | + dynamic: strict_allow_templates |
| 13 | + dynamic_templates: [ |
| 14 | + { |
| 15 | + strings: { |
| 16 | + "match": "stringField*", |
| 17 | + "match_mapping_type": "string", |
| 18 | + "mapping": { |
| 19 | + "type": "keyword" |
| 20 | + } |
| 21 | + } |
| 22 | + }, |
| 23 | + { |
| 24 | + object: { |
| 25 | + "match": "objectField*", |
| 26 | + "match_mapping_type": "object", |
| 27 | + "mapping": { |
| 28 | + "type": "object", |
| 29 | + "properties": { |
| 30 | + "bar1": { |
| 31 | + "type": "keyword" |
| 32 | + }, |
| 33 | + "bar2": { |
| 34 | + "type": "text" |
| 35 | + } |
| 36 | + } |
| 37 | + } |
| 38 | + } |
| 39 | + }, |
| 40 | + { |
| 41 | + boolean: { |
| 42 | + "match": "booleanField*", |
| 43 | + "match_mapping_type": "boolean", |
| 44 | + "mapping": { |
| 45 | + "type": "boolean" |
| 46 | + } |
| 47 | + } |
| 48 | + }, |
| 49 | + { |
| 50 | + double: { |
| 51 | + "match": "doubleField*", |
| 52 | + "match_mapping_type": "double", |
| 53 | + "mapping": { |
| 54 | + "type": "double" |
| 55 | + } |
| 56 | + } |
| 57 | + }, |
| 58 | + { |
| 59 | + long: { |
| 60 | + "match": "longField*", |
| 61 | + "match_mapping_type": "long", |
| 62 | + "mapping": { |
| 63 | + "type": "long" |
| 64 | + } |
| 65 | + } |
| 66 | + }, |
| 67 | + { |
| 68 | + array: { |
| 69 | + "match": "arrayField*", |
| 70 | + "mapping": { |
| 71 | + "type": "keyword" |
| 72 | + } |
| 73 | + } |
| 74 | + }, |
| 75 | + { |
| 76 | + date: { |
| 77 | + "match": "dateField*", |
| 78 | + "match_mapping_type": "date", |
| 79 | + "mapping": { |
| 80 | + "type": "date" |
| 81 | + } |
| 82 | + } |
| 83 | + } |
| 84 | + ] |
| 85 | + properties: |
| 86 | + test1: |
| 87 | + type: text |
| 88 | + |
| 89 | + - do: |
| 90 | + catch: /mapping set to strict_allow_templates, dynamic introduction of \[test2\] within \[\_doc\] is not allowed/ |
| 91 | + index: |
| 92 | + index: test_1 |
| 93 | + id: 1 |
| 94 | + body: { |
| 95 | + stringField: bar, |
| 96 | + objectField: { |
| 97 | + bar1: "bar1", |
| 98 | + bar2: "bar2" |
| 99 | + }, |
| 100 | + test1: test1, |
| 101 | + test2: test2 |
| 102 | + } |
| 103 | + |
| 104 | + - do: |
| 105 | + index: |
| 106 | + index: test_1 |
| 107 | + id: 1 |
| 108 | + body: { |
| 109 | + stringField: bar, |
| 110 | + objectField: { |
| 111 | + bar1: "bar1", |
| 112 | + bar2: "bar2" |
| 113 | + }, |
| 114 | + booleanField: true, |
| 115 | + doubleField: 1.0, |
| 116 | + longField: 100, |
| 117 | + arrayField: ["1","2"], |
| 118 | + dateField: "2024-06-25T05:11:51.243Z", |
| 119 | + test1: test1 |
| 120 | + } |
| 121 | + |
| 122 | + - do: |
| 123 | + get: |
| 124 | + index: test_1 |
| 125 | + id: 1 |
| 126 | + - match: { _source: { |
| 127 | + stringField: bar, |
| 128 | + objectField: { |
| 129 | + bar1: "bar1", |
| 130 | + bar2: "bar2" |
| 131 | + }, |
| 132 | + booleanField: true, |
| 133 | + doubleField: 1.0, |
| 134 | + longField: 100, |
| 135 | + arrayField: [ "1","2" ], |
| 136 | + dateField: "2024-06-25T05:11:51.243Z", |
| 137 | + test1: test1 |
| 138 | + } |
| 139 | + } |
| 140 | + |
| 141 | + - do: |
| 142 | + indices.get_mapping: { |
| 143 | + index: test_1 |
| 144 | + } |
| 145 | + |
| 146 | + - match: {test_1.mappings.dynamic: strict_allow_templates} |
| 147 | + - match: {test_1.mappings.properties.stringField.type: keyword} |
| 148 | + - match: {test_1.mappings.properties.objectField.properties.bar1.type: keyword} |
| 149 | + - match: {test_1.mappings.properties.objectField.properties.bar2.type: text} |
| 150 | + - match: {test_1.mappings.properties.booleanField.type: boolean} |
| 151 | + - match: {test_1.mappings.properties.doubleField.type: double} |
| 152 | + - match: {test_1.mappings.properties.longField.type: long} |
| 153 | + - match: {test_1.mappings.properties.arrayField.type: keyword} |
| 154 | + - match: {test_1.mappings.properties.dateField.type: date} |
| 155 | + - match: {test_1.mappings.properties.test1.type: text} |
0 commit comments