Skip to content

Commit cd6d025

Browse files
committed
move index creation into setup
1 parent ea79bd0 commit cd6d025

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

docs/includes/fundamentals/read-operations/ReadOperationsTest.php

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,10 @@ protected function setUp(): void
3030
['title' => 'movie_b', 'plot' => 'love is a long story'],
3131
['title' => 'movie_c', 'plot' => 'went on a trip'],
3232
]);
33+
34+
$collection = MongoDB::connection('mongodb')->collection('movies');
35+
$index = ['plot' => 'text'];
36+
$collection->createIndex($index);
3337
}
3438

3539
/**
@@ -119,11 +123,6 @@ public function testText(): void
119123
*/
120124
public function testTextRelevance(): void
121125
{
122-
123-
$collection = MongoDB::connection('mongodb')->collection('movies');
124-
$index = ['plot' => 'text'];
125-
$collection->createIndex($index);
126-
127126
// start-text-relevance
128127
$movies = Movie::where('$text', ['$search' => '"love story"'])
129128
->orderBy('score', ['$meta' => 'textScore'])

0 commit comments

Comments
 (0)