-
-
Notifications
You must be signed in to change notification settings - Fork 504
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add $search stage to aggregation pipeline builder #2516
Conversation
Creating as a draft for initial review until #2515 is merged. |
use Doctrine\ODM\MongoDB\Aggregation\Stage\Search\CompoundSearchOperatorInterface; | ||
use Doctrine\ODM\MongoDB\Aggregation\Stage\Search\SupportsCompoundableOperatorsTrait; | ||
|
||
class CompoundedAutocomplete extends Autocomplete implements CompoundSearchOperatorInterface |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All of these compounded operator classes could be created as anonymous classes, but that trips psalm into an endless recursion: vimeo/psalm#9573.
0e931c9
to
abdd8b4
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here's a first pass.
FYI: I had trouble following what all of the compound operator classes were used for. I understand the syntax in Atlas Search (although just barely), but this was too much to wrap my head around in a PR.
lib/Doctrine/ODM/MongoDB/Aggregation/Stage/Search/MoreLikeThis.php
Outdated
Show resolved
Hide resolved
lib/Doctrine/ODM/MongoDB/Aggregation/Stage/Search/AbstractSearchOperator.php
Outdated
Show resolved
Hide resolved
Yeah, that's where stuff gets messy. In a nutshell, the
This is constructed using: $builder->search()
->text()
->query('jmikola')
->path('content') However, when using compound, one can combine multiple operators in one of four conditions (must, mustNot, should, filter). For example: $builder->search()
->compound()
->must()
->text()->query('jmikola')->path('content')
->equals()->value('alcaeus')->path('author')
->mustNot()
->text()->query('bad words')->path('content') In this case, the result of The idea behind all this is to not rely on some |
* Add $search stage to aggregation pipeline builder * Make AbstractSearchOperator::getExpression final * Make appendScore method private for scored operators * Add documentation links to search operator classes * Separate wildcard and regex search operators
Summary
This adds the
$search
aggregation pipeline stage to the aggregation builder. This stage only works on MongoDB Atlas with Search indexes.The following is missing from this PR:
span
operator - I'm currently looking into the documentation as it is using undocumented operatorsfacet
collector - this is relevant for the$searchMeta
stage but would conflict with thefacet
stage that people could add down the line. For now, users should use the$$SEARCH_META
aggregation variable$search
stage itself.