2424import com .carrotsearch .hppc .cursors .ObjectCursor ;
2525import com .carrotsearch .hppc .cursors .ObjectObjectCursor ;
2626
27+ import org .elasticsearch .Assertions ;
2728import org .elasticsearch .Version ;
2829import org .elasticsearch .action .admin .indices .rollover .RolloverInfo ;
2930import org .elasticsearch .action .support .ActiveShardCount ;
@@ -1258,6 +1259,7 @@ public static IndexMetaData fromXContent(XContentParser parser) throws IOExcepti
12581259 if (token != XContentParser .Token .START_OBJECT ) {
12591260 throw new IllegalArgumentException ("expected object but got a " + token );
12601261 }
1262+ boolean mappingVersion = false ;
12611263 while ((token = parser .nextToken ()) != XContentParser .Token .END_OBJECT ) {
12621264 if (token == XContentParser .Token .FIELD_NAME ) {
12631265 currentFieldName = parser .currentName ();
@@ -1357,6 +1359,7 @@ public static IndexMetaData fromXContent(XContentParser parser) throws IOExcepti
13571359 } else if (KEY_VERSION .equals (currentFieldName )) {
13581360 builder .version (parser .longValue ());
13591361 } else if (KEY_MAPPING_VERSION .equals (currentFieldName )) {
1362+ mappingVersion = true ;
13601363 builder .mappingVersion (parser .longValue ());
13611364 } else if (KEY_ROUTING_NUM_SHARDS .equals (currentFieldName )) {
13621365 builder .setRoutingNumShards (parser .intValue ());
@@ -1367,6 +1370,9 @@ public static IndexMetaData fromXContent(XContentParser parser) throws IOExcepti
13671370 throw new IllegalArgumentException ("Unexpected token " + token );
13681371 }
13691372 }
1373+ if (Assertions .ENABLED && Version .indexCreated (builder .settings ).onOrAfter (Version .V_7_0_0_alpha1 )) {
1374+ assert mappingVersion : "mapping version should be present for indices created on or after 7.0.0" ;
1375+ }
13701376 return builder .build ();
13711377 }
13721378 }
0 commit comments