Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions lib/Doctrine/ODM/MongoDB/Aggregation/Stage.php
Original file line number Diff line number Diff line change
Expand Up @@ -368,10 +368,14 @@ public function sample(int $size): Stage\Sample
* The $search stage performs a full-text search on the specified field or
* fields which must be covered by an Atlas Search index.
*
* @deprecated Since doctrine/mongodb-odm 2.13. This $search stage must be the first of the pipeline, use Builder::search() instead.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I realize this is ODM and not PHPLIB's builder, but is there not a use case for creating your own pipeline with a list of Stage objects where it might still make sense to use a $search Stage?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Builder is a required dependency of the Stage classes. You cannot create stages without builder. Calling ->search from an existing stage means that you append the search stage after the current stage, which is never allowed.

*
* @see https://www.mongodb.com/docs/atlas/atlas-search/query-syntax/#mongodb-pipeline-pipe.-search
*/
public function search(): Stage\Search
{
trigger_deprecation('doctrine/mongodb-odm', '2.13', 'Using "%s" is deprecated because the $search stage must be the first of the pipeline, use "%s::search()" instead.', __METHOD__, Builder::class);

return $this->builder->search();
}

Expand Down