I am using MongoDb with laravel.
Below is my users collection sample json data
{
"_id" : "52dfcd17daf02a2e6cb396c7",
"email" : "nikhil@gmail.com",
"name" : "Nikhil"
}
{
"_id" : "52e0f9a2daf02ac908064f68",
"email" : Michael@gmail.com,
"name" : "Michael"
}
I have created index for 2 columns in collection, which is name & email.
db.users.ensureIndex({'email':'text', 'name': 'text'})
When i search for name I get the data but when i search exactly for an email id it gives unexpected results which should have been the emailId record.
Here is my code
$users = Users::whereRaw(['$text' => ['$search' => 'example@gmail.com']])->paginate(20);
return response()->view('users.view',
[
'users' => $users,
'title' => 'Search results for your query: ' . $query
]);
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire