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 ;
@@ -520,7 +521,7 @@ public function testSearchIndex(): void
520521 });
521522
522523 $ index = $ this ->getSearchIndex ('newcollection ' , 'default ' );
523- self ::assertNotFalse ($ index );
524+ self ::assertNotNull ($ index );
524525
525526 self ::assertSame ('default ' , $ index ['name ' ]);
526527 self ::assertSame ('search ' , $ index ['type ' ]);
@@ -541,7 +542,7 @@ public function testVectorSearchIndex()
541542 });
542543
543544 $ index = $ this ->getSearchIndex ('newcollection ' , 'vector ' );
544- self ::assertNotFalse ($ index );
545+ self ::assertNotNull ($ index );
545546
546547 self ::assertSame ('vector ' , $ index ['name ' ]);
547548 self ::assertSame ('vectorSearch ' , $ index ['type ' ]);
@@ -562,15 +563,15 @@ protected function getIndex(string $collection, string $name)
562563 return false ;
563564 }
564565
565- protected function getSearchIndex (string $ collection , string $ name )
566+ protected function getSearchIndex (string $ collection , string $ name ): ? Document
566567 {
567568 $ collection = DB ::getCollection ($ collection );
568569 assert ($ collection instanceof Collection);
569570
570- foreach ($ collection ->listSearchIndexes (['name ' => $ name ]) as $ index ) {
571+ foreach ($ collection ->listSearchIndexes (['name ' => $ name, ' typeMap ' => [ ' root ' => ' bson ' ] ]) as $ index ) {
571572 return $ index ;
572573 }
573574
574- return false ;
575+ return null ;
575576 }
576577}
0 commit comments