@@ -150,19 +150,27 @@ public void testSimpleGetFieldMappingsWithDefaults() throws Exception {
150
150
151
151
client ().prepareIndex ("test" , "type" , "1" ).setSource ("num" , 1 ).get ();
152
152
153
- GetFieldMappingsResponse response = client ().admin ().indices ().prepareGetFieldMappings ()
154
- .setFields ("num" , "field1" , "obj.subfield" ).includeDefaults (true ).get ();
155
-
156
- assertThat ((Map <String , Object >) response .fieldMappings ("test" , "type" , "num" ).sourceAsMap ().get ("num" ),
157
- hasEntry ("index" , Boolean .TRUE ));
158
- assertThat ((Map <String , Object >) response .fieldMappings ("test" , "type" , "num" ).sourceAsMap ().get ("num" ),
159
- hasEntry ("type" , "long" ));
160
- assertThat ((Map <String , Object >) response .fieldMappings ("test" , "type" , "field1" ).sourceAsMap ().get ("field1" ),
161
- hasEntry ("index" , Boolean .TRUE ));
162
- assertThat ((Map <String , Object >) response .fieldMappings ("test" , "type" , "field1" ).sourceAsMap ().get ("field1" ),
163
- hasEntry ("type" , "text" ));
164
- assertThat ((Map <String , Object >) response .fieldMappings ("test" , "type" , "obj.subfield" ).sourceAsMap ().get ("subfield" ),
165
- hasEntry ("type" , "keyword" ));
153
+ // we need to await busily for the mapping because we don't require acking on the dynamic mapping of an index request.
154
+ assertBusy (() -> {
155
+ GetFieldMappingsResponse response = client ().admin ().indices ().prepareGetFieldMappings ()
156
+ .setFields ("num" , "field1" , "obj.subfield" ).includeDefaults (true ).get ();
157
+
158
+ assertNotNull (response .fieldMappings ("test" , "type" , "num" ));
159
+ assertThat ((Map <String , Object >) response .fieldMappings ("test" , "type" , "num" ).sourceAsMap ().get ("num" ),
160
+ hasEntry ("index" , Boolean .TRUE ));
161
+ assertThat ((Map <String , Object >) response .fieldMappings ("test" , "type" , "num" ).sourceAsMap ().get ("num" ),
162
+ hasEntry ("type" , "long" ));
163
+
164
+ assertNotNull (response .fieldMappings ("test" , "type" , "field1" ));
165
+ assertThat ((Map <String , Object >) response .fieldMappings ("test" , "type" , "field1" ).sourceAsMap ().get ("field1" ),
166
+ hasEntry ("index" , Boolean .TRUE ));
167
+ assertThat ((Map <String , Object >) response .fieldMappings ("test" , "type" , "field1" ).sourceAsMap ().get ("field1" ),
168
+ hasEntry ("type" , "text" ));
169
+
170
+ assertNotNull (response .fieldMappings ("test" , "type" , "obj.subfield" ));
171
+ assertThat ((Map <String , Object >) response .fieldMappings ("test" , "type" , "obj.subfield" ).sourceAsMap ().get ("subfield" ),
172
+ hasEntry ("type" , "keyword" ));
173
+ });
166
174
}
167
175
168
176
@ SuppressWarnings ("unchecked" )
0 commit comments