-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
55 lines (49 loc) · 1.34 KB
/
main.go
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
46
47
48
49
50
51
52
53
54
55
package main
import (
"context"
"log"
"github.com/qdrant/go-client/qdrant"
)
func main() {
// The Go client uses Qdrant's gRPC interface
client, err := qdrant.NewClient(&qdrant.Config{
Host: "localhost",
Port: 6334,
})
if err != nil {
log.Fatalf("qdrant connection failed %s", err)
}
if err := client.CreateCollection(context.Background(), &qdrant.CreateCollection{
CollectionName: "eli_collection",
VectorsConfig: qdrant.NewVectorsConfig(&qdrant.VectorParams{
Size: 4,
Distance: qdrant.Distance_Dot,
}),
}); err != nil {
log.Fatalf("failed to create collection %s", err)
}
operationInfo, err := client.Upsert(context.Background(), &qdrant.UpsertPoints{
CollectionName: "eli_collection",
Points: []*qdrant.PointStruct{
{
Id: qdrant.NewIDNum(1),
Vectors: qdrant.NewVectors(0.05, 0.61, 0.76, 0.74),
Payload: qdrant.NewValueMap(map[string]any{"city": "Berlin"}),
},
{
Id: qdrant.NewIDNum(2),
Vectors: qdrant.NewVectors(0.19, 0.81, 0.75, 0.11),
Payload: qdrant.NewValueMap(map[string]any{"city": "London"}),
},
{
Id: qdrant.NewIDNum(3),
Vectors: qdrant.NewVectors(0.36, 0.55, 0.47, 0.94),
Payload: qdrant.NewValueMap(map[string]any{"city": "Moscow"}),
},
},
})
if err != nil {
log.Fatalf("failed to do upsert %s", err)
}
log.Println(operationInfo)
}