Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[9.x] Add command delete-all-indexes, update scout:index to allow FQCN and apply filterable on SoftDeletes #671

Merged
merged 7 commits into from
Dec 9, 2022

Conversation

kichetof
Copy link
Contributor

@kichetof kichetof commented Dec 9, 2022

This PR add some new features for Meilisearch:

  • scout:index accept a FQCN as name argument.
  • Apply filterable attribute on __soft_deleted when Model use SoftDeletes at index creation.
  • Added a new command to delete all indexes (only Meilisearch support it).

With this addition, your Scout.php config file will not look like this crazy repetition:

'meilisearch' => [
    'host' => env('MEILISEARCH_HOST', 'http://localhost:7700'),
    'key' => env('MEILISEARCH_KEY', null),
    'index-settings' => [
        Model_A::class => [
            'filterableAttributes' => ['__soft_deleted'],
        ],
        Model_B::class => [
            'filterableAttributes' => ['__soft_deleted'],
        ],
        Model_C::class => [
            'filterableAttributes' => ['__soft_deleted'],
        ],
        Model_D::class => [
            'filterableAttributes' => ['__soft_deleted'],
        ],
        // ....
        Model_Y::class => [
            'filterableAttributes' => ['__soft_deleted'],
        ],
        Model_Z::class => [
            'filterableAttributes' => ['__soft_deleted'],
        ],
    ],
]

@kichetof kichetof changed the title [9.x] Add command delete-all-indexes [9.x] Add command delete-all-indexes, update scout:index to allow FQCN and apply filterable on SoftDeletes Dec 9, 2022
@taylorotwell
Copy link
Member

Made some changes to this. I removed the auto-addition of __soft_deleted as that was not consistently carried through to sync-index-settings command which felt inconsistent.

I also actually registered the command in the service provider, which raised some concern to me as the command would not have been invokable otherwise and therefore I'm not sure how it could have been tested even manually? Did you try to run this code?

@taylorotwell
Copy link
Member

Verified this all works on my Sail installation. Thanks.

@taylorotwell taylorotwell merged commit 7d5e527 into laravel:9.x Dec 9, 2022
@kichetof
Copy link
Contributor Author

kichetof commented Dec 9, 2022

Thanks for merging it! (delete-all-indexes come from my own custom command and I totally forgot to commit provider, thanks!)

I'll think over the weekend how to add __soft_deleted out of the box. I've an idea to add it on sync-index-settings command, let's see after a break :)

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

Successfully merging this pull request may close these issues.

2 participants