yabhq / laravel-scout-mysql-driver

Laravel Scout MySQL Driver
MIT License
522 stars 113 forks source link

Search query Looking for '__soft_deleted' column #79

Open codemenorg opened 5 years ago

codemenorg commented 5 years ago

My test returns this error:

SQLSTATE[42S22]: Column not found: 1054 Unknown column '__soft_deleted' in 'where clause' (SQL: select count(*) as aggregate from `posts` where __soft_deleted = 0 AND MATCH(country,state,city,address,patient_avatar) AGAINST(Ismail IN NATURAL LANGUAGE MODE) and `posts`.`deleted_at` is null)

Any suggestion to solve this problem?

NB: I am using scout for first time.

chris-doco commented 4 years ago

In my case, I was trying to search for only deleted models. This worked for me:

Model::search($text, function ($query) {
    return $query->onlyTrashed();
});
liamc-sty commented 4 years ago

In my case, I was trying to search for only deleted models. This worked for me:

Model::search($text, function ($query) {
    return $query->onlyTrashed();
});

I am trying to query onlyTrashed models but this solution did not work for me - I still get the same error as OP.

I have changed the 'soft_delete' boolean to 'true' in app/scout.php, and flushed & re-indexed using php artisan scout.

Anything else to try here?

Taelkir commented 3 years ago

In my case, I was trying to search for only deleted models. This worked for me:

Model::search($text, function ($query) {
    return $query->onlyTrashed();
});

This pushed me in the right direction; I'm running this:

MyModel::search($text, function ($query) {
    return $query->onlyTrashed();
})->get();

While having the 'soft_delete' boolean set to 'false' in app/scout.php - it didn't work with this boolean set to true as I would then run into the error mentioned at the top of this issue.

elbaylot commented 3 years ago

In my case, I was trying to search for only deleted models. This worked for me:

Model::search($text, function ($query) {
    return $query->onlyTrashed();
});

This pushed me in the right direction; I'm running this:

MyModel::search($text, function ($query) {
    return $query->onlyTrashed();
})->get();

While having the 'soft_delete' boolean set to 'false' in app/scout.php - it didn't work with this boolean set to true as I would then run into the error mentioned at the top of this issue.

Thanks, work also for me with callback in search method and config boolean set to false.