Skip to content

shouldBeSearchable is not called during processing of MakeSearchable #933

@aleem-dubizzlelabs

Description

@aleem-dubizzlelabs

Scout Version

10.1.0

Scout Driver

Typesense

Laravel Version

9

PHP Version

8.1

Database Driver & Version

No response

SDK Version

No response

Meilisearch CLI Version

No response

Description

Laravel Scout is syncing all User model records even though the shouldBeSearchable() method is defined to filter them. The method is being ignored because searchable() is called on the full collection (User::all()), which bypasses the shouldBeSearchable() logic.

Steps To Reproduce

Define a shouldBeSearchable() method in your model (e.g., User):

public function shouldBeSearchable()
{
    return $this->is_active;
}

Run this code to sync the models:

User::all()->searchable();
Observe that all users are indexed, including those where is_active = false.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions