typesense / typesense-go

Go client for Typesense: https://github.com/typesense/typesense
Apache License 2.0
208 stars 55 forks source link

Collection is "" if it's not set #168

Open leapoly opened 2 months ago

leapoly commented 2 months ago

Description

If the collection is not set in the multiSerachCollectionParameters, the client will send an empty string, which is not valid.

Steps to reproduce

image

The body of the request will be:

{
    "searches": [
        {
            "collection": "",
            "filter_by": "(active:true \\u0026\\u0026 closed:false) || (active:true \\u0026\\u0026 closed:true)",
            "include_fields": "id",
            "preset": "Events",
            "q": "trump"
        },
        {
            "collection": "",
            "include_fields": "id",
            "preset": "Tags",
            "q": "trump"
        },
        {
            "collection": "",
            "include_fields": "id",
            "preset": "Profiles",
            "q": "trump"
        }
    ]
}

Expected Behavior

It shouldn't be sent because I'm using a Preset that has a collection.

Actual Behavior

It makes the search in the collection "" that does not exist.

Metadata

Typesense Version: 1.1.0

OS: Mac

kishorenc commented 2 months ago

The collection name field is a string and not a pointer, like other fields, so it's sent as empty string when not set. We will have to probably handle this in Typesense end because changing the collection type to pointer.String will break existing client conventions. I will take a look and post an update here.