4242import org .elasticsearch .test .ESSingleNodeTestCase ;
4343
4444import java .io .IOException ;
45- import java .util .List ;
4645
4746import static java .util .Collections .emptyMap ;
4847import static org .elasticsearch .common .xcontent .XContentFactory .jsonBuilder ;
@@ -245,7 +244,17 @@ public void testField() throws Exception {
245244 // original mapping not modified
246245 assertEquals (mapping , serialize (mapper ));
247246 // but we have an update
248- assertEquals ("{\" type\" :{\" properties\" :{\" foo\" :{\" type\" :\" text\" }}}}" , serialize (update ));
247+ assertEquals (XContentFactory .jsonBuilder ().startObject ().startObject ("type" ).startObject ("properties" )
248+ .startObject ("foo" )
249+ .field ("type" , "text" )
250+ .startObject ("fields" )
251+ .startObject ("keyword" )
252+ .field ("type" , "keyword" )
253+ .field ("ignore_above" , 256 )
254+ .endObject ()
255+ .endObject ()
256+ .endObject ()
257+ .endObject ().endObject ().endObject ().string (), serialize (update ));
249258 }
250259
251260 public void testIncremental () throws Exception {
@@ -267,7 +276,14 @@ public void testIncremental() throws Exception {
267276 // but we have an update
268277 assertEquals (XContentFactory .jsonBuilder ().startObject ().startObject ("type" ).startObject ("properties" )
269278 // foo is NOT in the update
270- .startObject ("bar" ).field ("type" , "text" ).endObject ()
279+ .startObject ("bar" ).field ("type" , "text" )
280+ .startObject ("fields" )
281+ .startObject ("keyword" )
282+ .field ("type" , "keyword" )
283+ .field ("ignore_above" , 256 )
284+ .endObject ()
285+ .endObject ()
286+ .endObject ()
271287 .endObject ().endObject ().string (), serialize (update ));
272288 }
273289
@@ -287,8 +303,22 @@ public void testIntroduceTwoFields() throws Exception {
287303 assertEquals (mapping , serialize (mapper ));
288304 // but we have an update
289305 assertEquals (XContentFactory .jsonBuilder ().startObject ().startObject ("type" ).startObject ("properties" )
290- .startObject ("bar" ).field ("type" , "text" ).endObject ()
291- .startObject ("foo" ).field ("type" , "text" ).endObject ()
306+ .startObject ("bar" ).field ("type" , "text" )
307+ .startObject ("fields" )
308+ .startObject ("keyword" )
309+ .field ("type" , "keyword" )
310+ .field ("ignore_above" , 256 )
311+ .endObject ()
312+ .endObject ()
313+ .endObject ()
314+ .startObject ("foo" ).field ("type" , "text" )
315+ .startObject ("fields" )
316+ .startObject ("keyword" )
317+ .field ("type" , "keyword" )
318+ .field ("ignore_above" , 256 )
319+ .endObject ()
320+ .endObject ()
321+ .endObject ()
292322 .endObject ().endObject ().string (), serialize (update ));
293323 }
294324
@@ -308,7 +338,9 @@ public void testObject() throws Exception {
308338 assertEquals (mapping , serialize (mapper ));
309339 // but we have an update
310340 assertEquals (XContentFactory .jsonBuilder ().startObject ().startObject ("type" ).startObject ("properties" )
311- .startObject ("foo" ).startObject ("properties" ).startObject ("bar" ).startObject ("properties" ).startObject ("baz" ).field ("type" , "text" ).endObject ().endObject ().endObject ().endObject ().endObject ()
341+ .startObject ("foo" ).startObject ("properties" ).startObject ("bar" ).startObject ("properties" ).startObject ("baz" ).field ("type" , "text" )
342+ .startObject ("fields" ).startObject ("keyword" ).field ("type" , "keyword" ).field ("ignore_above" , 256 ).endObject ()
343+ .endObject ().endObject ().endObject ().endObject ().endObject ().endObject ()
312344 .endObject ().endObject ().endObject ().string (), serialize (update ));
313345 }
314346
@@ -328,7 +360,15 @@ public void testArray() throws Exception {
328360 assertEquals (mapping , serialize (mapper ));
329361 // but we have an update
330362 assertEquals (XContentFactory .jsonBuilder ().startObject ().startObject ("type" ).startObject ("properties" )
331- .startObject ("foo" ).field ("type" , "text" ).endObject ()
363+ .startObject ("foo" )
364+ .field ("type" , "text" )
365+ .startObject ("fields" )
366+ .startObject ("keyword" )
367+ .field ("type" , "keyword" )
368+ .field ("ignore_above" , 256 )
369+ .endObject ()
370+ .endObject ()
371+ .endObject ()
332372 .endObject ().endObject ().endObject ().string (), serialize (update ));
333373 }
334374
@@ -348,7 +388,9 @@ public void testInnerDynamicMapping() throws Exception {
348388 assertEquals (mapping , serialize (mapper ));
349389 // but we have an update
350390 assertEquals (XContentFactory .jsonBuilder ().startObject ().startObject ("type" ).startObject ("properties" )
351- .startObject ("foo" ).startObject ("properties" ).startObject ("bar" ).startObject ("properties" ).startObject ("baz" ).field ("type" , "text" ).endObject ().endObject ().endObject ().endObject ().endObject ()
391+ .startObject ("foo" ).startObject ("properties" ).startObject ("bar" ).startObject ("properties" ).startObject ("baz" ).field ("type" , "text" ).startObject ("fields" )
392+ .startObject ("keyword" ).field ("type" , "keyword" ).field ("ignore_above" , 256 ).endObject ()
393+ .endObject ().endObject ().endObject ().endObject ().endObject ().endObject ()
352394 .endObject ().endObject ().endObject ().string (), serialize (update ));
353395 }
354396
@@ -369,7 +411,14 @@ public void testComplexArray() throws Exception {
369411 assertEquals (mapping , serialize (mapper ));
370412 assertEquals (XContentFactory .jsonBuilder ().startObject ().startObject ("type" ).startObject ("properties" )
371413 .startObject ("foo" ).startObject ("properties" )
372- .startObject ("bar" ).field ("type" , "text" ).endObject ()
414+ .startObject ("bar" ).field ("type" , "text" )
415+ .startObject ("fields" )
416+ .startObject ("keyword" )
417+ .field ("type" , "keyword" )
418+ .field ("ignore_above" , 256 )
419+ .endObject ()
420+ .endObject ()
421+ .endObject ()
373422 .startObject ("baz" ).field ("type" , "long" ).endObject ()
374423 .endObject ().endObject ()
375424 .endObject ().endObject ().endObject ().string (), serialize (update ));
0 commit comments