typesense / typesense/typesense-go
Add support for generics
Open
Nobody has claimed this yet.
- Dominant language
- Go
- Stars
- 319
- Forks
- 73
- PR merge metrics
- No merged PRs in 30d
Description
Search results are untyped (map[string]any) which makes this very unergonomic to use
Currently we're working around it with a custom search method
func searchCollection[TDoc any](ctx context.Context, collection string, params *api.SearchCollectionParams) (*Result[TDoc], error) {
resp, err := typesenseApiClient.SearchCollection(ctx, collection, params)
if err != nil {
return nil, err
}
defer resp.Body.Close()
if resp.StatusCode > 299 {
return nil, utils.ErrHighStatusCode
}
var results Result[TDoc]
err = json.NewDecoder(resp.Body).Decode(&results)
if err != nil {
return nil, err
}
return &results, nil
}
and matching types
type Result[TDoc any] struct {
GroupedHits []GroupedHit[TDoc] `json:"grouped_hits,omitempty"`
Hits []*ResultHit[TDoc] `json:"hits,omitempty"`
...
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at SearchCollection and the existing Result, GroupedHit, and ResultHit types; compare them with the custom generic implementation shown in the issue. Determine the supported generic search-result API and the affected response shapes. Done means callers can receive typed search results without maintaining a custom search method.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go
- Domain
- api, search
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100