Skip to content

Conversation

@GromNaN
Copy link
Member

@GromNaN GromNaN commented Sep 9, 2025

Q A
Type bug
BC Break yes
Fixed issues -

Summary

$search must be the first stage of any pipeline it appears in.

And mentioned in the ODM doc:

$search
-------
The ``$search`` stage performs a full-text search on the specified field or
fields which must be covered by an Atlas Search index. This stage is only
available when using MongoDB Atlas. ``$search`` must be the first stage in the
aggregation pipeline.

@GromNaN GromNaN changed the title Deprecate Stage::search() because the $search stage must be the first of the pipeline Deprecate Stage::search() because the $search stage must be the first of the pipeline Sep 10, 2025
@GromNaN GromNaN requested a review from jmikola September 10, 2025 09:20
Copy link
Member

@jmikola jmikola left a comment

Choose a reason for hiding this comment

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

One question just for my understanding, but I assume you know what you're doing here 😄

* 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.

@GromNaN GromNaN merged commit 2a9118a into doctrine:2.13.x Sep 14, 2025
21 checks passed
@GromNaN GromNaN deleted the remove-stage-search branch September 14, 2025 18:47
@GromNaN GromNaN added this to the 2.13.0 milestone Sep 18, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants