Skip to content

Commit 73d6b94

Browse files
authored
DOCSP-46269 Fix doc examples on atlas search (#3279)
1 parent e4fd2d6 commit 73d6b94

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

docs/includes/fundamentals/as-avs/AtlasSearchTest.php

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
use MongoDB\Driver\Exception\ServerException;
1212
use MongoDB\Laravel\Schema\Builder;
1313
use MongoDB\Laravel\Tests\TestCase;
14+
use PHPUnit\Framework\Attributes\Group;
1415

1516
use function array_map;
1617
use function mt_getrandmax;
@@ -19,6 +20,7 @@
1920
use function srand;
2021
use function usleep;
2122

23+
#[Group('atlas-search')]
2224
class AtlasSearchTest extends TestCase
2325
{
2426
private array $vectors;
@@ -84,7 +86,7 @@ protected function setUp(): void
8486
do {
8587
$ready = true;
8688
usleep(10_000);
87-
foreach ($collection->listSearchIndexes() as $index) {
89+
foreach ($moviesCollection->listSearchIndexes() as $index) {
8890
if ($index['status'] !== 'READY') {
8991
$ready = false;
9092
}
@@ -102,7 +104,7 @@ public function testSimpleSearch(): void
102104
$movies = Movie::search(
103105
sort: ['title' => 1],
104106
operator: Search::text('title', 'dream'),
105-
)->get();
107+
)->all();
106108
// end-search-query
107109

108110
$this->assertNotNull($movies);
@@ -113,10 +115,10 @@ public function testSimpleSearch(): void
113115
* @runInSeparateProcess
114116
* @preserveGlobalState disabled
115117
*/
116-
public function autocompleteSearchTest(): void
118+
public function testAutocompleteSearch(): void
117119
{
118120
// start-auto-query
119-
$movies = Movie::autocomplete('title', 'jak')->get();
121+
$movies = Movie::autocomplete('title', 'jak')->all();
120122
// end-auto-query
121123

122124
$this->assertNotNull($movies);
@@ -127,9 +129,9 @@ public function autocompleteSearchTest(): void
127129
* @runInSeparateProcess
128130
* @preserveGlobalState disabled
129131
*/
130-
public function vectorSearchTest(): void
132+
public function testVectorSearch(): void
131133
{
132-
$results = Book::vectorSearch(
134+
$results = Movie::vectorSearch(
133135
index: 'vector',
134136
path: 'vector4',
135137
queryVector: $this->vectors[0],
@@ -141,7 +143,7 @@ public function vectorSearchTest(): void
141143
);
142144

143145
$this->assertNotNull($results);
144-
$this->assertSame('C', $results->first()->title);
146+
$this->assertSame('D', $results->first()->title);
145147
}
146148

147149
/** Generates random vectors using fixed seed to make tests deterministic */

0 commit comments

Comments
 (0)