|
6 | 6 |
|
7 | 7 | use Illuminate\Database\Eloquent\Builder as EloquentBuilder;
|
8 | 8 | use MongoDB\BSON\Document;
|
| 9 | +use MongoDB\Builder\Type\SearchOperatorInterface; |
9 | 10 | use MongoDB\Driver\CursorInterface;
|
10 | 11 | use MongoDB\Driver\Exception\WriteException;
|
11 | 12 | use MongoDB\Laravel\Connection;
|
@@ -70,9 +71,38 @@ public function aggregate($function = null, $columns = ['*'])
|
70 | 71 | return $result ?: $this;
|
71 | 72 | }
|
72 | 73 |
|
73 |
| - public function search(...$args) |
74 |
| - { |
75 |
| - $results = $this->toBase()->search(...$args); |
| 74 | + /** |
| 75 | + * Performs a full-text search of the field or fields in an Atlas collection. |
| 76 | + * NOTE: $search is only available for MongoDB Atlas clusters, and is not available for self-managed deployments. |
| 77 | + * |
| 78 | + * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/search/ |
| 79 | + * |
| 80 | + * @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. |
| 81 | + * @param ?string $index Name of the Atlas Search index to use. If omitted, defaults to "default". |
| 82 | + * @param ?array $highlight Specifies the highlighting options for displaying search terms in their original context. |
| 83 | + * @param ?bool $concurrent Parallelize search across segments on dedicated search nodes. |
| 84 | + * @param ?string $count Document that specifies the count options for retrieving a count of the results. |
| 85 | + * @param ?string $searchAfter Reference point for retrieving results. searchAfter returns documents starting immediately following the specified reference point. |
| 86 | + * @param ?string $searchBefore Reference point for retrieving results. searchBefore returns documents starting immediately before the specified reference point. |
| 87 | + * @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. |
| 88 | + * @param ?array $sort Document that specifies the fields to sort the Atlas Search results by in ascending or descending order. |
| 89 | + * @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. |
| 90 | + * @param ?array $tracking Document that specifies the tracking option to retrieve analytics information on the search terms. |
| 91 | + */ |
| 92 | + public function search( |
| 93 | + SearchOperatorInterface|array $operator, |
| 94 | + ?string $index = null, |
| 95 | + ?array $highlight = null, |
| 96 | + ?bool $concurrent = null, |
| 97 | + ?string $count = null, |
| 98 | + ?string $searchAfter = null, |
| 99 | + ?string $searchBefore = null, |
| 100 | + ?bool $scoreDetails = null, |
| 101 | + ?array $sort = null, |
| 102 | + ?bool $returnStoredSource = null, |
| 103 | + ?array $tracking = null, |
| 104 | + ) { |
| 105 | + $results = $this->toBase()->search($operator, $index, $highlight, $concurrent, $count, $searchAfter, $searchBefore, $scoreDetails, $sort, $returnStoredSource, $tracking); |
76 | 106 |
|
77 | 107 | return $this->model->hydrate($results->all());
|
78 | 108 | }
|
|
0 commit comments