77use Illuminate \Support \Facades \DB ;
88use Illuminate \Support \Facades \Schema ;
99use MongoDB \BSON \Binary ;
10+ use MongoDB \BSON \Document ;
1011use MongoDB \BSON \UTCDateTime ;
1112use MongoDB \Collection ;
1213use MongoDB \Laravel \Schema \Blueprint ;
@@ -541,7 +542,7 @@ public function testSearchIndex(): void
541542 });
542543
543544 $ index = $ this ->getSearchIndex ('newcollection ' , 'default ' );
544- self ::assertNotFalse ($ index );
545+ self ::assertNotNull ($ index );
545546
546547 self ::assertSame ('default ' , $ index ['name ' ]);
547548 self ::assertSame ('search ' , $ index ['type ' ]);
@@ -562,7 +563,7 @@ public function testVectorSearchIndex()
562563 });
563564
564565 $ index = $ this ->getSearchIndex ('newcollection ' , 'vector ' );
565- self ::assertNotFalse ($ index );
566+ self ::assertNotNull ($ index );
566567
567568 self ::assertSame ('vector ' , $ index ['name ' ]);
568569 self ::assertSame ('vectorSearch ' , $ index ['type ' ]);
@@ -583,15 +584,15 @@ protected function getIndex(string $collection, string $name)
583584 return false ;
584585 }
585586
586- protected function getSearchIndex (string $ collection , string $ name )
587+ protected function getSearchIndex (string $ collection , string $ name ): ? Document
587588 {
588589 $ collection = DB ::getCollection ($ collection );
589590 assert ($ collection instanceof Collection);
590591
591- foreach ($ collection ->listSearchIndexes (['name ' => $ name ]) as $ index ) {
592+ foreach ($ collection ->listSearchIndexes (['name ' => $ name, ' typeMap ' => [ ' root ' => ' bson ' ] ]) as $ index ) {
592593 return $ index ;
593594 }
594595
595- return false ;
596+ return null ;
596597 }
597598}
0 commit comments