@@ -114,18 +114,62 @@ public void testConfigureStoredSourceBeforeIndexCreation() throws IOException {
114
114
}
115
115
}""" ;
116
116
117
+ assertOK (putComponentTemplate (client , "logs@custom" , storedSourceMapping ));
118
+ assertOK (createDataStream (client , "logs-custom-dev" ));
119
+
120
+ var mapping = getMapping (client , getDataStreamBackingIndex (client , "logs-custom-dev" , 0 ));
121
+ String sourceMode = (String ) subObject ("_source" ).apply (mapping ).get ("mode" );
122
+ assertThat (sourceMode , equalTo ("stored" ));
123
+ }
124
+
125
+ public void testConfigureDisabledSourceBeforeIndexCreation () {
126
+ var storedSourceMapping = """
127
+ {
128
+ "template": {
129
+ "settings": {
130
+ "index": {
131
+ "mode": "logsdb"
132
+ }
133
+ },
134
+ "mappings": {
135
+ "_source": {
136
+ "enabled": false
137
+ }
138
+ }
139
+ }
140
+ }""" ;
141
+
117
142
Exception e = assertThrows (ResponseException .class , () -> putComponentTemplate (client , "logs@custom" , storedSourceMapping ));
118
143
assertThat (
119
144
e .getMessage (),
120
- containsString ("Failed to parse mapping: Indices with with index mode [logsdb] only support synthetic source " )
145
+ containsString ("Failed to parse mapping: _source can not be disabled in index using [logsdb] index mode " )
121
146
);
122
147
assertThat (e .getMessage (), containsString ("mapper_parsing_exception" ));
148
+ }
123
149
124
- assertOK (createDataStream (client , "logs-custom-dev" ));
150
+ public void testConfigureDisabledSourceModeBeforeIndexCreation () {
151
+ var storedSourceMapping = """
152
+ {
153
+ "template": {
154
+ "settings": {
155
+ "index": {
156
+ "mode": "logsdb"
157
+ }
158
+ },
159
+ "mappings": {
160
+ "_source": {
161
+ "mode": "disabled"
162
+ }
163
+ }
164
+ }
165
+ }""" ;
125
166
126
- var mapping = getMapping (client , getDataStreamBackingIndex (client , "logs-custom-dev" , 0 ));
127
- String sourceMode = (String ) subObject ("_source" ).apply (mapping ).get ("mode" );
128
- assertThat (sourceMode , equalTo ("synthetic" ));
167
+ Exception e = assertThrows (ResponseException .class , () -> putComponentTemplate (client , "logs@custom" , storedSourceMapping ));
168
+ assertThat (
169
+ e .getMessage (),
170
+ containsString ("Failed to parse mapping: _source can not be disabled in index using [logsdb] index mode" )
171
+ );
172
+ assertThat (e .getMessage (), containsString ("mapper_parsing_exception" ));
129
173
}
130
174
131
175
public void testConfigureStoredSourceWhenIndexIsCreated () throws IOException {
@@ -141,8 +185,45 @@ public void testConfigureStoredSourceWhenIndexIsCreated() throws IOException {
141
185
}""" ;
142
186
143
187
assertOK (putComponentTemplate (client , "logs@custom" , storedSourceMapping ));
188
+ assertOK (createDataStream (client , "logs-custom-dev" ));
189
+
190
+ var mapping = getMapping (client , getDataStreamBackingIndex (client , "logs-custom-dev" , 0 ));
191
+ String sourceMode = (String ) subObject ("_source" ).apply (mapping ).get ("mode" );
192
+ assertThat (sourceMode , equalTo ("stored" ));
193
+ }
194
+
195
+ public void testConfigureDisabledSourceWhenIndexIsCreated () throws IOException {
196
+ var disabledModeMapping = """
197
+ {
198
+ "template": {
199
+ "mappings": {
200
+ "_source": {
201
+ "enabled": false
202
+ }
203
+ }
204
+ }
205
+ }""" ;
206
+
207
+ assertOK (putComponentTemplate (client , "logs@custom" , disabledModeMapping ));
208
+ ResponseException e = expectThrows (ResponseException .class , () -> createDataStream (client , "logs-custom-dev" ));
209
+ assertThat (e .getMessage (), containsString ("_source can not be disabled in index using [logsdb] index mode" ));
210
+ }
211
+
212
+ public void testConfigureDisabledSourceModeWhenIndexIsCreated () throws IOException {
213
+ var disabledModeMapping = """
214
+ {
215
+ "template": {
216
+ "mappings": {
217
+ "_source": {
218
+ "mode": "disabled"
219
+ }
220
+ }
221
+ }
222
+ }""" ;
223
+
224
+ assertOK (putComponentTemplate (client , "logs@custom" , disabledModeMapping ));
144
225
ResponseException e = expectThrows (ResponseException .class , () -> createDataStream (client , "logs-custom-dev" ));
145
- assertThat (e .getMessage (), containsString ("Indices with with index mode [logsdb] only support synthetic source " ));
226
+ assertThat (e .getMessage (), containsString ("_source can not be disabled in index using [logsdb] index mode " ));
146
227
}
147
228
148
229
public void testOverrideIndexCodec () throws IOException {
0 commit comments