7
7
use Illuminate \Support \Facades \DB ;
8
8
use Illuminate \Support \Facades \Schema ;
9
9
use MongoDB \BSON \Binary ;
10
+ use MongoDB \BSON \Document ;
10
11
use MongoDB \BSON \UTCDateTime ;
11
12
use MongoDB \Collection ;
12
13
use MongoDB \Laravel \Schema \Blueprint ;
@@ -541,7 +542,7 @@ public function testSearchIndex(): void
541
542
});
542
543
543
544
$ index = $ this ->getSearchIndex ('newcollection ' , 'default ' );
544
- self ::assertNotFalse ($ index );
545
+ self ::assertNotNull ($ index );
545
546
546
547
self ::assertSame ('default ' , $ index ['name ' ]);
547
548
self ::assertSame ('search ' , $ index ['type ' ]);
@@ -562,7 +563,7 @@ public function testVectorSearchIndex()
562
563
});
563
564
564
565
$ index = $ this ->getSearchIndex ('newcollection ' , 'vector ' );
565
- self ::assertNotFalse ($ index );
566
+ self ::assertNotNull ($ index );
566
567
567
568
self ::assertSame ('vector ' , $ index ['name ' ]);
568
569
self ::assertSame ('vectorSearch ' , $ index ['type ' ]);
@@ -583,15 +584,15 @@ protected function getIndex(string $collection, string $name)
583
584
return false ;
584
585
}
585
586
586
- protected function getSearchIndex (string $ collection , string $ name )
587
+ protected function getSearchIndex (string $ collection , string $ name ): ? Document
587
588
{
588
589
$ collection = DB ::getCollection ($ collection );
589
590
assert ($ collection instanceof Collection);
590
591
591
- foreach ($ collection ->listSearchIndexes (['name ' => $ name ]) as $ index ) {
592
+ foreach ($ collection ->listSearchIndexes (['name ' => $ name, ' typeMap ' => [ ' root ' => ' bson ' ] ]) as $ index ) {
592
593
return $ index ;
593
594
}
594
595
595
- return false ;
596
+ return null ;
596
597
}
597
598
}
0 commit comments