doctrine / mongodb-odm

The Official PHP MongoDB ORM/ODM
https://www.doctrine-project.org/projects/doctrine-mongodb-odm/en/latest/
MIT License
1.09k stars 502 forks source link

Add $search the official aggregation stage for running search queries #2460

Open Alaarafeh opened 2 years ago

Alaarafeh commented 2 years ago

Doctrine\ODM\MongoDB\Aggregation\Stage we have all possible aggregation stages excapt two Stages:

  1. $search
  2. $searchMeta

Useful links: https://www.mongodb.com/docs/atlas/atlas-search/query-syntax/

malarzm commented 2 years ago

@Alaarafeh would you be interested in submitting a PR adding missing stages and tests for them?

Alaarafeh commented 2 years ago

@malarzm i could give try i have already patch in my project and works for me , i will try to create PR but i don't know what version policy you have as PR (should i create new branch from current version as bug/feature) ? and which kind of tests you used (unit, integration or functional)?

malarzm commented 2 years ago

should i create new branch from current version as bug/feature

Your contribution will be a feature in 2.5. Please target 2.4.x branch for now however, I'll take care of branching 2.5.x off once I'm done with bringing back CI to life.

which kind of tests you used

Functional test is not needed, we're mostly interested whether the stage produces correct query after usage. Something like https://github.com/doctrine/mongodb-odm/blob/2.4.x/tests/Doctrine/ODM/MongoDB/Tests/Aggregation/Stage/LookupTest.php or https://github.com/doctrine/mongodb-odm/blob/2.4.x/tests/Doctrine/ODM/MongoDB/Tests/Aggregation/Stage/CountTest.php :)

malarzm commented 2 years ago

@Alaarafeh 2.5.x was just created, please start your work from there whenever you have a chance :)

GromNaN commented 1 year ago

There is 2 sides for this feature:

  1. Defining Atlas Search Indexes
  2. Add $search operators to the aggregation stages
alcaeus commented 1 year ago

2516 adds the $search stage to the aggregation builder, along with almost all operators that the stage supports.

Defining Atlas Search index currently isn't possible through the driver, but only through the UI. The documentation will contain information on how to set up these indexes, but there is a project at MongoDB to expose search index creation to the drivers. I have no further information on the timeline of that yet.