Skip to content

Commit 6abce65

Browse files
committed
Improve docs
1 parent ed5c8f7 commit 6abce65

File tree

1 file changed

+25
-14
lines changed

1 file changed

+25
-14
lines changed

src/Query/Builder.php

Lines changed: 25 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1497,19 +1497,9 @@ public function options(array $options)
14971497
* Performs a full-text search of the field or fields in an Atlas collection.
14981498
* NOTE: $search is only available for MongoDB Atlas clusters, and is not available for self-managed deployments.
14991499
*
1500-
* @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/search/
1500+
* @see https://www.mongodb.com/docs/atlas/atlas-search/aggregation-stages/search/
15011501
*
1502-
* @param SearchOperatorInterface|array $operator Operator to search with. You can provide a specific operator or use the compound operator to run a compound query with multiple operators.
1503-
* @param ?string $index Name of the Atlas Search index to use. If omitted, defaults to "default".
1504-
* @param ?array $highlight Specifies the highlighting options for displaying search terms in their original context.
1505-
* @param ?bool $concurrent Parallelize search across segments on dedicated search nodes.
1506-
* @param ?string $count Document that specifies the count options for retrieving a count of the results.
1507-
* @param ?string $searchAfter Reference point for retrieving results. searchAfter returns documents starting immediately following the specified reference point.
1508-
* @param ?string $searchBefore Reference point for retrieving results. searchBefore returns documents starting immediately before the specified reference point.
1509-
* @param ?bool $scoreDetails Flag that specifies whether to retrieve a detailed breakdown of the score for the documents in the results. If omitted, defaults to false.
1510-
* @param ?array $sort Document that specifies the fields to sort the Atlas Search results by in ascending or descending order.
1511-
* @param ?bool $returnStoredSource Flag that specifies whether to perform a full document lookup on the backend database or return only stored source fields directly from Atlas Search.
1512-
* @param ?array $tracking Document that specifies the tracking option to retrieve analytics information on the search terms.
1502+
* @return Collection<object|array>
15131503
*/
15141504
public function search(
15151505
SearchOperatorInterface|array $operator,
@@ -1524,12 +1514,33 @@ public function search(
15241514
?bool $returnStoredSource = null,
15251515
?array $tracking = null,
15261516
): Collection {
1527-
$args = array_filter(compact(['operator', 'index', 'highlight', 'concurrent', 'count', 'searchAfter', 'searchBefore', 'scoreDetails', 'sort', 'returnStoredSource', 'tracking']), fn ($arg) => $arg !== null);
1517+
// Forward named arguments to the search stage, skip null values
1518+
$args = array_filter([
1519+
'operator' => $operator,
1520+
'index' => $index,
1521+
'highlight' => $highlight,
1522+
'concurrent' => $concurrent,
1523+
'count' => $count,
1524+
'searchAfter' => $searchAfter,
1525+
'searchBefore' => $searchBefore,
1526+
'scoreDetails' => $scoreDetails,
1527+
'sort' => $sort,
1528+
'returnStoredSource' => $returnStoredSource,
1529+
'tracking' => $tracking,
1530+
], fn ($arg) => $arg !== null);
15281531

15291532
return $this->aggregate()->search(...$args)->get();
15301533
}
15311534

1532-
/** @return Collection<string> */
1535+
/**
1536+
* Performs an autocomplete search of the field using an Atlas Search index.
1537+
* NOTE: $search is only available for MongoDB Atlas clusters, and is not available for self-managed deployments.
1538+
* You must create an Atlas Search index with an autocomplete configuration before you can use this stage.
1539+
*
1540+
* @see https://www.mongodb.com/docs/atlas/atlas-search/autocomplete/
1541+
*
1542+
* @return Collection<string>
1543+
*/
15331544
public function autocomplete(string $path, string $query, bool|array $fuzzy = false, string $tokenOrder = 'any'): Collection
15341545
{
15351546
$args = ['path' => $path, 'query' => $query, 'tokenOrder' => $tokenOrder];

0 commit comments

Comments
 (0)