From d4e434869fde549e78e025106ebf9674e7e0a6c4 Mon Sep 17 00:00:00 2001 From: Gautier DELEGLISE Date: Mon, 11 Aug 2025 22:17:37 +0200 Subject: [PATCH 1/2] trashed text search --- content/2.endpoints/2.search.md | 34 ++++++++++++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) diff --git a/content/2.endpoints/2.search.md b/content/2.endpoints/2.search.md index 7e54202..fd4ddcb 100644 --- a/content/2.endpoints/2.search.md +++ b/content/2.endpoints/2.search.md @@ -573,4 +573,36 @@ When using full text search, some restrictions happens to the query: | `filters.type` | Not allowed | | `filters.nested` | Not allowed | | **Sorts** | | -| `sorts.field` | take scout fields instead of fields in resource detail | +| `sorts.field` | take scout fields instead of fields in resource detail | + + +#### Text search with trash + +Because the Laravel Scout Builder is not built the same as the Eloquent one, `withTrashed` instruction is not a scope +anymore and work differently: + +```json +// (POST) api/posts/search +{ + "search": { + "text": { + "value": "my text search", + "trashed": "with" + } + } +} +``` + +or for `onlyTrashed`: + +```json +// (POST) api/posts/search +{ + "search": { + "text": { + "value": "my text search", + "trashed": "only" + } + } +} +``` From 2f3423a8258ac268fd8c44dd63306e7ac778c358 Mon Sep 17 00:00:00 2001 From: Gautier DELEGLISE Date: Mon, 11 Aug 2025 22:24:37 +0200 Subject: [PATCH 2/2] Update 2.search.md --- content/2.endpoints/2.search.md | 53 +++++++++++++-------------------- 1 file changed, 21 insertions(+), 32 deletions(-) diff --git a/content/2.endpoints/2.search.md b/content/2.endpoints/2.search.md index fd4ddcb..30f13a3 100644 --- a/content/2.endpoints/2.search.md +++ b/content/2.endpoints/2.search.md @@ -562,24 +562,27 @@ If you want to specify a full text search you'll need to use the text argument. When using full text search, some restrictions happens to the query: -| **Key** | **Changes** | -|---------------------|--------------------------------------------------------| -| **Scopes** | | -| `scopes.name` | Not allowed | -| `scopes.parameters` | Not allowed | -| **Filters** | | -| `filters.field` | take scout fields instead of fields in resource detail | -| `filters.operator` | `=`/`in`/`not in` | -| `filters.type` | Not allowed | -| `filters.nested` | Not allowed | -| **Sorts** | | -| `sorts.field` | take scout fields instead of fields in resource detail | - - -#### Text search with trash - -Because the Laravel Scout Builder is not built the same as the Eloquent one, `withTrashed` instruction is not a scope -anymore and work differently: +| **Key** | **Changes** | +|---------------------|-----------------------------------------------------------------| +| **Scopes** | | +| `scopes.name` | Not allowed | +| `scopes.parameters` | Not allowed | +| **Filters** | | +| `filters.field` | take scout fields instead of fields in resource detail | +| `filters.operator` | `=`/`in`/`not in` | +| `filters.type` | Not allowed | +| `filters.nested` | Not allowed | +| **Sorts** | | +| `sorts.field` | uses Scout fields instead of fields defined in resource details | + +#### Text search with trashed models + +Because the Laravel Scout Builder differs from Eloquent, `withTrashed` is not a scope when performing text search. +Instead, control trashed handling via the `text.trashed` option: + +- "with" → include both non-trashed and trashed records +- "only" → include only trashed records +- omitted → exclude trashed records (default) ```json // (POST) api/posts/search @@ -592,17 +595,3 @@ anymore and work differently: } } ``` - -or for `onlyTrashed`: - -```json -// (POST) api/posts/search -{ - "search": { - "text": { - "value": "my text search", - "trashed": "only" - } - } -} -```