{"id":15324231,"url":"https://github.com/baderkha/typesense","last_synced_at":"2026-01-07T04:43:18.762Z","repository":{"id":57778448,"uuid":"527556307","full_name":"baderkha/typesense","owner":"baderkha","description":"An Unofficial Typesense client that uses generics","archived":false,"fork":false,"pushed_at":"2022-08-25T04:27:06.000Z","size":124,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-01T21:14:26.467Z","etag":null,"topics":["client","elastic","generics","go","rest","typesense"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/baderkha.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-08-22T12:32:47.000Z","updated_at":"2022-08-25T22:03:18.000Z","dependencies_parsed_at":"2022-08-27T12:52:15.083Z","dependency_job_id":null,"html_url":"https://github.com/baderkha/typesense","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/baderkha%2Ftypesense","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/baderkha%2Ftypesense/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/baderkha%2Ftypesense/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/baderkha%2Ftypesense/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/baderkha","download_url":"https://codeload.github.com/baderkha/typesense/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245898331,"owners_count":20690466,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["client","elastic","generics","go","rest","typesense"],"created_at":"2024-10-01T09:25:18.447Z","updated_at":"2026-01-07T04:43:18.734Z","avatar_url":"https://github.com/baderkha.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003ch1 align=\"center\"\u003eTypesense Generic Client GoLang [Unofficial]\u003c/h1\u003e\n\nThis project is an implementation of the rest api proided by Typesense .\n\nFor more information see https://typesense.org/docs/ . I would like to iterate that this is the Unofficial package.\n\nIf you're looking for the offical one please see https://github.com/typesense/typesense-go\n\n## Features\n\n- Support For Generics out of the box .\n  - no passing interface{} anys\n  - no Unmarshalling on your end\n- Testability from a consumer's perspective built in the code\n  - All the Clients in the code bases are interfaces\n  - Mocks are also provided for all of them if you don't want to generate your own\n- Modular Implementation\n  - You can extend the imlementations any way you like\n- Fluent Argument Builders\n- Migration Built out of the box .\n  - Automatic migration and Manual Migration Supported.\n  - Aliasing ..etc\n  - Tools to help you do your own migration logic\n- Schema Attributes like index , sorting , facets ... etc supported with struct tags\n- Logging Support (thanks to the amazing http client resty ! see https://github.com/go-resty/resty)\n\n## Quick Start Guide\n\nQuickly Creating a new instance , indexing and querying the documents\n\n### 1) Installation\n\n```bash\ngo get github.com/baderkha/typesense\n```\n\n### 2) Code Example With Basic Operations\n\n- For Full Example go to https://github.com/baderkha/typesense/blob/main/cmd/example/example.go\n\n* Define a Type\n\n  ```go\n\n  // UserData : a Typical model you would write for your api\n  type UserData struct {\n  \t// your id , can be generated by you uuid , or typesense can handle it\n  \tID        string `json:\"id\"`\n  \tFirstName string `json:\"first_name\" tsense_required:\"1\"`\n  \t// by default all fields are optional unless you specify otherwise\n  \tLastName string `json:\"last_name\" tsense_required:\"true\"`\n  \t// faceting\n  \tEmail string `json:\"email\" tsense_required:\"true\" tsense_facet:\"1\"`\n  \t// default sorting\n  \tGPA float32 `json:\"gpa\" tsense_default_sort:\"1\"`\n  \t// default type any int is int64 , you can always override this\n  \tVisit     int32 `json:\"visit\" tsense_type:\"int32\"`\n  \tIsDeleted bool  `json:\"is_deleted\"  tsense_required:\"true\"`\n  \t// by default time.Time is not supported since time isn't supported in typesense\n  \t//this overrides this issue by turning your time data into unix epoch\n  \tCreatedAt types.Timestamp `json:\"created_at\"  tsense_required:\"true\"`\n  \tUpdatedAt types.Timestamp `json:\"updated_at\"  tsense_required:\"true\"`\n  }\n  ```\n\n* Init Client\n\n  ```go\n  apiKey := os.Getenv(\"TYPESENSE_API_KEY\")\n  host := os.Getenv(\"TYPESENSE_URL\")\n  logging := os.Getenv(\"TYPESENSE_LOGGING\") == \"TRUE\"\n  // main facade client\n  client := typesense.NewClient[UserData](apiKey, host, logging)\n  ```\n\n* Migrate Model\n\n  ```go\n  // this method will 2 resources\n  // first is a collection with a version ie user_data_2022-10-10_\u003csome-uuid\u003e\n  // second it will create an alias called user_data -\u003e user_data_2022-10-10_\u003csome-uuid\u003e\n  //\n  // See the typesense documentation to understand the benefits of aliasing\n  err := client.Migration().Auto()\n  if err != nil {\n  \tlog.Fatal(err)\n  }\n\n  ```\n\n* Index A Document\n\n  ```go\n  // Document\n  // This method will creat a record under your collection\n  // your document will know exactly what collection to write it to\n  err = client.Document().Index(\n    \u0026UserData{\n  \tID:        \"some-uuid-for-this\",\n  \tFirstName: \"Barry\",\n  \tLastName:  \"Allen\",\n  \tEmail:     \"barry_allen@someFakeEmail.com\",\n  \tGPA:       4.00,\n  \tVisit:     50,\n  \tIsDeleted: false,\n  \tCreatedAt: types.Timestamp(time.Now()),\n  \tUpdatedAt: types.Timestamp(time.Now()),\n  \t},\n  )\n  ```\n\n* Get Document\n  ```go\n  // Document\n  // this method will get the record we just created and return back\n  // a *User pointer without us having to init a var and pass as reference\n  // neet right ?\n  doc, err := client.Document().GetById(\"some-uuid-for-this\")\n  ```\n* Search For Documents\n\n  ```go\n\n  // english : give me everyone with the name of barry by first and last name\n  // Give me that data as the first page + 20 per page max\n  //\n  // this is fluent so you can keep adding args and it will build the struct for you\n  searchQuery := typesense.\n  \tNewSearchParams().\n  \tAddSearchTerm(\"barry\").\n  \tAddQueryBy(\"first_name,last_name\").\n  \tAddPage(1).\n  \tAddPerPage(20)\n\n  // Search\n  // This method will do a filter search / fuzzy search\n  // res is of type typesense.SearchResult[UserData]\n  res, err := client.Search().Search(searchQuery)\n  ```\n\n---\n\n## Author : Ahmad Baderkhan ❤️☀️💚\n\n## License : MIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbaderkha%2Ftypesense","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbaderkha%2Ftypesense","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbaderkha%2Ftypesense/lists"}