Skip to content
This repository has been archived by the owner on Jan 9, 2024. It is now read-only.

Search query Looking for '__soft_deleted' column #79

Open
codemenorg opened this issue Feb 9, 2019 · 4 comments
Open

Search query Looking for '__soft_deleted' column #79

codemenorg opened this issue Feb 9, 2019 · 4 comments

Comments

@codemenorg
Copy link

codemenorg commented Feb 9, 2019

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
Copy link

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
Copy link

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
Copy link

Taelkir commented Sep 28, 2021

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
Copy link

elbaylot commented Nov 4, 2021

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.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants