forked from cr7258/kubernetes-guide
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprebuild.go
More file actions
executable file
·45 lines (39 loc) · 1.17 KB
/
prebuild.go
File metadata and controls
executable file
·45 lines (39 loc) · 1.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
package main
import (
"fmt"
pb "github.com/qdrant/go-client/qdrant"
"log"
"myembedding/pkg/helpers/qdrant"
)
var urls = []string{
"https://stackoverflow.com/questions/42564058/how-to-use-local-docker-images-with-minikube",
"https://stackoverflow.com/questions/59980445/setting-image-pull-policy-using-kubectl",
"https://stackoverflow.com/questions/47909256/how-to-use-apply-instead-of-create-for-deployment-in-kubernetes",
}
func main() {
// 判断 collection 是否存在
collectionExist, err := qdrant.HasCollection("kubernetes")
if err != nil {
log.Fatalln("获取collection出错:", err.Error())
}
if collectionExist == false {
//创建 collection: kubernetes
err := qdrant.Collection("kubernetes").Create(1536)
if err != nil {
log.Fatalln("创建collection出错:", err.Error())
}
}
points := []*pb.PointStruct{}
for _, _url := range urls {
p, err := qdrant.BuildPointByUrl(_url)
if err != nil {
log.Fatalln("创建point出错:", err.Error())
}
points = append(points, p)
fmt.Println(p.Id.String())
}
err = qdrant.FastQdrantClient.CreatePoints("kubernetes", points)
if err != nil {
log.Fatalln("批量创建point出错:", err.Error())
}
}