File tree Expand file tree Collapse file tree 3 files changed +25
-2
lines changed
Expand file tree Collapse file tree 3 files changed +25
-2
lines changed Original file line number Diff line number Diff line change 8787 * quantization?: 'none'|'scalar'|'binary',
8888 * } | array{
8989 * type: 'filter',
90- * path: string,
90+ * path: string,
9191 * }
9292 * @phpstan-type TypeVectorSearchIndexDefinition array{
9393 * fields: array<string, TypeVectorSearchIndexField>,
Original file line number Diff line number Diff line change @@ -504,9 +504,10 @@ public function testGetIndexes()
504504 $ this ->assertSame ([], $ indexes );
505505 }
506506
507- /** @todo requires SearchIndex support */
508507 public function testSearchIndex (): void
509508 {
509+ $ this ->skipIfSearchIndexManagementIsNotSupported ();
510+
510511 Schema::create ('newcollection ' , function (Blueprint $ collection ) {
511512 $ collection ->searchIndex ([
512513 'mappings ' => [
@@ -529,6 +530,8 @@ public function testSearchIndex(): void
529530
530531 public function testVectorSearchIndex ()
531532 {
533+ $ this ->skipIfSearchIndexManagementIsNotSupported ();
534+
532535 Schema::create ('newcollection ' , function (Blueprint $ collection ) {
533536 $ collection ->vectorSearchIndex ([
534537 'fields ' => [
Original file line number Diff line number Diff line change 55namespace MongoDB \Laravel \Tests ;
66
77use Illuminate \Foundation \Application ;
8+ use MongoDB \Driver \Exception \ServerException ;
89use MongoDB \Laravel \MongoDBServiceProvider ;
910use MongoDB \Laravel \Tests \Models \User ;
1011use MongoDB \Laravel \Validation \ValidationServiceProvider ;
@@ -64,4 +65,23 @@ protected function getEnvironmentSetUp($app): void
6465 $ app ['config ' ]->set ('queue.failed.database ' , 'mongodb2 ' );
6566 $ app ['config ' ]->set ('queue.failed.driver ' , 'mongodb ' );
6667 }
68+
69+ public function skipIfSearchIndexManagementIsNotSupported (): void
70+ {
71+ try {
72+ $ this ->getConnection ('mongodb ' )->getCollection ('test ' )->listSearchIndexes (['name ' => 'just_for_testing ' ]);
73+ } catch (ServerException $ e ) {
74+ switch ($ e ->getCode ()) {
75+ // MongoDB 6: Unrecognized pipeline stage name: '$listSearchIndexes'
76+ case 40324 :
77+ // MongoDB 7: PlanExecutor error during aggregation :: caused by :: Search index commands are only supported with Atlas.
78+ case 115 :
79+ // MongoDB 8: Using Atlas Search Database Commands and the $listSearchIndexes aggregation stage requires additional configuration.
80+ case 31082 :
81+ self ::markTestSkipped ('Search index management is not supported on this server ' );
82+ }
83+
84+ throw $ e ;
85+ }
86+ }
6787}
You can’t perform that action at this time.
0 commit comments