-
Notifications
You must be signed in to change notification settings - Fork 1.5k
-
Hello , is this possible to search using this one :
https://www.mongodb.com/atlas/search
any example for this , or just using normal search ?
thanks
Beta Was this translation helpful? Give feedback.
All reactions
Yes, it is possible using a raw aggregation. There is an example in the mongodb library: https://github.com/mongodb/mongo-php-library/blob/0017da3d475a7795cb0577f4991b385992e51573/examples/atlas-search.php#L98
To use with laravel:
use MongoDB\Laravel\Collection; YourModel::raw(function (Collection $collection) { return $collection->aggregate([ [ '$search' => [ 'index' => 'default', 'text' => [ 'query' => <text>, 'path' => [<field>], ], ], ], ['$limit' => 10], ] }));
Replies: 1 comment 2 replies
-
Yes, it is possible using a raw aggregation. There is an example in the mongodb library: https://github.com/mongodb/mongo-php-library/blob/0017da3d475a7795cb0577f4991b385992e51573/examples/atlas-search.php#L98
To use with laravel:
use MongoDB\Laravel\Collection; YourModel::raw(function (Collection $collection) { return $collection->aggregate([ [ '$search' => [ 'index' => 'default', 'text' => [ 'query' => <text>, 'path' => [<field>], ], ], ], ['$limit' => 10], ] }));
Beta Was this translation helpful? Give feedback.
All reactions
-
🎉 1
-
thanks a lot @GromNaN ,
in Atlas search there is a score in result
how to showing score in this result ?
Beta Was this translation helpful? Give feedback.
All reactions
-
I don't know Atlas Search enough to answer. You can look at the $search
documentation. For Laravel integration, you can add an attribute to your model to receive this the score value (don't save it).
Beta Was this translation helpful? Give feedback.