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 ;
@@ -520,7 +521,7 @@ public function testSearchIndex(): void
520
521
});
521
522
522
523
$ index = $ this ->getSearchIndex ('newcollection ' , 'default ' );
523
- self ::assertNotFalse ($ index );
524
+ self ::assertNotNull ($ index );
524
525
525
526
self ::assertSame ('default ' , $ index ['name ' ]);
526
527
self ::assertSame ('search ' , $ index ['type ' ]);
@@ -541,7 +542,7 @@ public function testVectorSearchIndex()
541
542
});
542
543
543
544
$ index = $ this ->getSearchIndex ('newcollection ' , 'vector ' );
544
- self ::assertNotFalse ($ index );
545
+ self ::assertNotNull ($ index );
545
546
546
547
self ::assertSame ('vector ' , $ index ['name ' ]);
547
548
self ::assertSame ('vectorSearch ' , $ index ['type ' ]);
@@ -562,15 +563,15 @@ protected function getIndex(string $collection, string $name)
562
563
return false ;
563
564
}
564
565
565
- protected function getSearchIndex (string $ collection , string $ name )
566
+ protected function getSearchIndex (string $ collection , string $ name ): ? Document
566
567
{
567
568
$ collection = DB ::getCollection ($ collection );
568
569
assert ($ collection instanceof Collection);
569
570
570
- foreach ($ collection ->listSearchIndexes (['name ' => $ name ]) as $ index ) {
571
+ foreach ($ collection ->listSearchIndexes (['name ' => $ name, ' typeMap ' => [ ' root ' => ' bson ' ] ]) as $ index ) {
571
572
return $ index ;
572
573
}
573
574
574
- return false ;
575
+ return null ;
575
576
}
576
577
}
0 commit comments