Skip to content

Passing "empty" values to search query results in "Parameter q is required" #83

Open
@justrau

Description

@justrau

Description

When using certain values for query string, "Parameter q is required" is thrown. More exactly, any value that returns true from empty(...) does not work.

Steps to reproduce

For example, App\Models\Taxon::search("0")->get() throws an error.

Expected Behavior

Found values should be returned.

Actual Behavior

"Parameter q is required" is thrown.

Metadata

Typesense Version:
0.25.1

OS:

Culprit

https://github.com/typesense/laravel-scout-typesense-driver/blob/master/src/Engines/TypesenseEngine.php#L208 and https://github.com/typesense/laravel-scout-typesense-driver/blob/master/src/Engines/TypesenseEngine.php#L208 runs array_filter on parameters array, therefore, removing the "0" query param, and typesense request is then missing the q parameter.

Possible solution

Change array_filter to a stricter function, such as rejecting only null values.

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