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

Allow Typesense Search Parameter Definition on Models #827

Merged
merged 2 commits into from
May 6, 2024

Conversation

stammbach
Copy link
Contributor

@stammbach stammbach commented May 3, 2024

Added the optional typesenseSearchParameters Model Definition to allow declaration of Typesense Search Parameters using Models to extend and streamline the already existing typesenseCollectionSchema functionality.

Currently when utilising the existing typesenseCollectionSchema function, you have to mix and match Model based Defintion with Config Usage, which is not ideal.

With the added typesenseSearchParameters you can define everything utilising only Models.

Before After

File: Model.php

public function typesenseCollectionSchema(): array
{
    return [
        'enable_nested_fields' => true,
        'fields' => [
            [
                'name' => '.*',
                'type' => 'auto',
            ],
        ],
    ];
}

with

File: config/scout.php

return [
    'typesense' => [
        'model-settings' => [
            Model::class => [
                'search-parameters' => [
                    'query_by' => 'name'
                ]
            ]
        ]
    ]
];

File: Model.php

public function typesenseCollectionSchema(): array
{
    return [
        'enable_nested_fields' => true,
        'fields' => [
            [
                'name' => '.*',
                'type' => 'auto',
            ],
        ],
    ];
}

public function typesenseSearchParameters(): array
{
    return [
        'query_by' => 'name'
    ];
}

@taylorotwell taylorotwell merged commit e8fa704 into laravel:10.x May 6, 2024
13 checks passed
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