@@ -645,21 +645,16 @@ const updateExistingDataStream = async ({
645
645
esClient : ElasticsearchClient ;
646
646
logger : Logger ;
647
647
} ) => {
648
- const dataStreamResponse = await esClient . indices . getDataStream ( { name : dataStreamName } ) ;
649
- const currentBackingIndex =
650
- dataStreamResponse . data_streams [ 0 ] . indices [
651
- dataStreamResponse . data_streams [ 0 ] . indices . length - 1
652
- ] ;
653
-
654
- const currentBackingIndexData = (
655
- await esClient . indices . get ( {
656
- index : currentBackingIndex . index_name ,
657
- } )
658
- ) [ currentBackingIndex . index_name ] ;
659
-
660
- const currentIndexMode = currentBackingIndexData . settings ?. index ?. mode ;
661
- // @ts -expect-error
662
- const currentSourceType = currentBackingIndexData . mappings ?. _source ?. mode ;
648
+ const existingDs = await esClient . indices . get ( {
649
+ index : dataStreamName ,
650
+ } ) ;
651
+
652
+ const existingDsConfig = Object . values ( existingDs ) ;
653
+ const currentBackingIndexConfig = existingDsConfig [ existingDsConfig . length - 1 ] ;
654
+
655
+ const currentIndexMode = currentBackingIndexConfig ?. settings ?. index ?. mode ;
656
+ // @ts -expect-error Property 'mode' does not exist on type 'MappingSourceField'
657
+ const currentSourceType = currentBackingIndexConfig . mappings ?. _source ?. mode ;
663
658
664
659
let settings : IndicesIndexSettings ;
665
660
let mappings : MappingTypeMapping ;
@@ -705,7 +700,7 @@ const updateExistingDataStream = async ({
705
700
// Trigger a rollover if the index mode or source type has changed
706
701
if (
707
702
currentIndexMode !== settings ?. index ?. mode ||
708
- // @ts -expect-error
703
+ // @ts -expect-error Property 'mode' does not exist on type 'MappingSourceField'
709
704
currentSourceType !== mappings ?. _source ?. mode
710
705
) {
711
706
logger . debug (
0 commit comments