CreateCollection creates a collection in qdrant
(name string, createCollectionRequest CreateCollectionRequest)
| 36 | |
| 37 | // CreateCollection creates a collection in qdrant |
| 38 | func CreateCollection(name string, createCollectionRequest CreateCollectionRequest) (err error) { |
| 39 | response := &CommonResponse{} |
| 40 | var reqBytes []byte |
| 41 | reqBytes, err = json.Marshal(createCollectionRequest) |
| 42 | if err != nil { |
| 43 | common.Logger.Error(err.Error()) |
| 44 | return |
| 45 | } |
| 46 | |
| 47 | body, err := Send(http.MethodPut, collectionApi+"/"+name, reqBytes) |
| 48 | if err != nil { |
| 49 | common.Logger.Error(err.Error()) |
| 50 | return |
| 51 | } |
| 52 | |
| 53 | err = json.Unmarshal(body, &response) |
| 54 | if err != nil { |
| 55 | return |
| 56 | } |
| 57 | if response.Result == nil { |
| 58 | return errors.New(response.Status.(map[string]interface{})["error"].(string)) |
| 59 | } |
| 60 | return |
| 61 | |
| 62 | } |
| 63 | |
| 64 | func GetCollection(name string) (err error) { |
| 65 | response := &CommonResponse{} |