@@ -409,18 +409,28 @@ Table buildTable(RestRequest request, IndexMetaData[] indicesMetaData, ClusterHe
409409 }
410410 }
411411
412- // the index is present in the cluster state but is not returned in the indices stats API
413- if (indexStats == null ) {
412+ // the open index is present in the cluster state but is not returned in the indices stats API
413+ if (indexStats == null && state != IndexMetaData . State . CLOSE ) {
414414 // the index stats API is called last, after cluster state and cluster health. If the index stats
415- // has not resolved the same indices as the initial cluster state call, then the indices might
415+ // has not resolved the same open indices as the initial cluster state call, then the indices might
416416 // have been removed in the meantime or, more likely, are unauthorized. This is because the cluster
417417 // state exposes everything, even unauthorized indices, which are not exposed in APIs.
418418 // We ignore such an index instead of displaying it with an empty stats.
419419 continue ;
420420 }
421421
422- final CommonStats primaryStats = indexStats .getPrimaries ();
423- final CommonStats totalStats = indexStats .getTotal ();
422+ final CommonStats primaryStats ;
423+ final CommonStats totalStats ;
424+
425+ if (state == IndexMetaData .State .CLOSE ) {
426+ // empty stats for closed indices, but their names are displayed
427+ assert indexStats == null ;
428+ primaryStats = new CommonStats ();
429+ totalStats = new CommonStats ();
430+ } else {
431+ primaryStats = indexStats .getPrimaries ();
432+ totalStats = indexStats .getTotal ();
433+ }
424434
425435 table .startRow ();
426436 table .addCell (state == IndexMetaData .State .OPEN ?
@@ -609,8 +619,8 @@ Table buildTable(RestRequest request, IndexMetaData[] indicesMetaData, ClusterHe
609619 table .addCell (totalStats .getSearch () == null ? null : totalStats .getSearch ().getTotal ().getSuggestCount ());
610620 table .addCell (primaryStats .getSearch () == null ? null : primaryStats .getSearch ().getTotal ().getSuggestCount ());
611621
612- table .addCell (indexStats . getTotal () .getTotalMemory ());
613- table .addCell (indexStats . getPrimaries () .getTotalMemory ());
622+ table .addCell (totalStats .getTotalMemory ());
623+ table .addCell (primaryStats .getTotalMemory ());
614624
615625 table .addCell (searchThrottled );
616626
0 commit comments