yabhq/laravel-scout-mysql-driver

Search query Looking for '__soft_deleted' column

codemenorg opened this issue · 4 comments

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.

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

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

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?

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.

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.