#community-help

Discrepancy in Function Argument Names in Typesense library

TLDR Jack noticed misnamed arguments in a typesense library function, causing confusion with other libraries. Kishore Nallan renamed the parameters for clarity. Jack opened a PR with the fix and Kishore Nallan merged it.

Powered by Struct AI

1

14
2mo
Solved
Join the chat
Sep 19, 2023 (2 months ago)
Jack
Photo of md5-763597f84b704376f42cabfa33614ae8
Jack
12:14 PM
Is it me or are the argument names for these functions the wrong way round?
https://github.com/typesense/typesense-go/blob/24486a683104574d73c3ee0f070facb671052391/typesense/multi_search.go#L13-L14

It seems like MultiSearchSearchesParameter contains the per-search parameters (as it contains a slice of MultiSearchCollectionParameters ), whereas MultiSearchParams contains the common parameters.
Kishore Nallan
Photo of md5-4e872368b2b2668460205b409e95c2ea
Kishore Nallan
12:19 PM
Are you talking about the order of the params in the function?
Jack
Photo of md5-763597f84b704376f42cabfa33614ae8
Jack
12:19 PM
The naming of them specifically
12:20
Jack
12:20 PM
Actually, the order doesn't match other libraries either
12:20
Jack
12:20 PM
The names do match other libraries though
12:20
Jack
12:20 PM
All other libraries accept [searchRequests, commonSearchParams], which this one appears to be doing based on the names, but the types are swapped.
Kishore Nallan
Photo of md5-4e872368b2b2668460205b409e95c2ea
Kishore Nallan
12:21 PM
Yes commonSearchParams is misleading. It must be searchSpecificParams
Jack
Photo of md5-763597f84b704376f42cabfa33614ae8
Jack
12:21 PM
I think the two argument names just need swapping, so searchParams becomes commonSearchParams and vice-versa.
12:22
Jack
12:22 PM
The order won't match other languages then but it's a non-breaking change at least.
Kishore Nallan
Photo of md5-4e872368b2b2668460205b409e95c2ea
Kishore Nallan
12:22 PM
Changing the order will probably break existing clients, so I can change the name to make it clearer.
Jack
Photo of md5-763597f84b704376f42cabfa33614ae8
Jack
12:22 PM
Yeah 👍 I can open a PR if you want?
Kishore Nallan
Photo of md5-4e872368b2b2668460205b409e95c2ea
Kishore Nallan
12:22 PM
Yes, please that would be great!
Kishore Nallan
Photo of md5-4e872368b2b2668460205b409e95c2ea
Kishore Nallan
12:28 PM
Merged! Thank you.

1

Typesense

Lightning-fast, open source search engine for everyone | Knowledge Base powered by Struct.AI

Indexed 3011 threads (79% resolved)

Join Our Community