CreateCollection creates a collection in Typesense based on the provided schema. If the collection already exists, it will return without error.
(ctx context.Context, schema *api.CollectionSchema)
| 201 | // CreateCollection creates a collection in Typesense based on the provided schema. |
| 202 | // If the collection already exists, it will return without error. |
| 203 | func (t *TypesenseClient) CreateCollection(ctx context.Context, schema *api.CollectionSchema) (*api.CollectionResponse, error) { |
| 204 | resp, err := t.Client.Collections().Create(ctx, schema) |
| 205 | if err != nil { |
| 206 | if strings.Contains(err.Error(), "already exists") { |
| 207 | return nil, nil |
| 208 | } |
| 209 | return nil, err |
| 210 | } |
| 211 | return resp, nil |
| 212 | } |
| 213 | |
| 214 | // Search performs a search query on a specific collection with the provided search parameters. |
| 215 | func (t *TypesenseClient) Search(ctx context.Context, collection string, searchParams *api.SearchCollectionParams) (*api.SearchResult, error) { |
no test coverage detected