-
Hello , is this possible to search using this one : any example for this , or just using normal search ? thanks |
Beta Was this translation helpful? Give feedback.
Answered by
GromNaN
Oct 9, 2023
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.
2 replies
Answer selected by
imunisasi
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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: