mirror of
https://github.com/qdrant/landing_page.git
synced 2026-10-09 21:08:31 +02:00
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
55 lines
1.2 KiB
Go
55 lines
1.2 KiB
Go
package snippet
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/qdrant/go-client/qdrant"
|
|
)
|
|
|
|
func Main() {
|
|
client, err := qdrant.NewClient(&qdrant.Config{
|
|
Host: "localhost",
|
|
Port: 6334,
|
|
})
|
|
|
|
if err != nil { panic(err) } // @hide
|
|
|
|
client.Upsert(context.Background(), &qdrant.UpsertPoints{
|
|
CollectionName: "documents",
|
|
Points: []*qdrant.PointStruct{
|
|
{
|
|
Id: qdrant.NewIDNum(200),
|
|
Vectors: qdrant.NewVectorsMap(map[string]*qdrant.Vector{}),
|
|
Payload: qdrant.NewValueMap(map[string]any{
|
|
"title": "Document A",
|
|
"text": "This is document A",
|
|
}),
|
|
},
|
|
{
|
|
Id: qdrant.NewIDNum(201),
|
|
Vectors: qdrant.NewVectorsMap(map[string]*qdrant.Vector{}),
|
|
Payload: qdrant.NewValueMap(map[string]any{
|
|
"title": "Document B",
|
|
"text": "This is document B",
|
|
}),
|
|
},
|
|
},
|
|
})
|
|
|
|
client.Upsert(context.Background(), &qdrant.UpsertPoints{
|
|
CollectionName: "chunks",
|
|
Points: []*qdrant.PointStruct{
|
|
{
|
|
Id: qdrant.NewIDNum(0),
|
|
Vectors: qdrant.NewVectors(0.1, 0.2, 0.3, 0.4),
|
|
Payload: qdrant.NewValueMap(map[string]any{"document_id": 200}),
|
|
},
|
|
{
|
|
Id: qdrant.NewIDNum(1),
|
|
Vectors: qdrant.NewVectors(0.5, 0.6, 0.7, 0.8),
|
|
Payload: qdrant.NewValueMap(map[string]any{"document_id": []int{200, 201}}),
|
|
},
|
|
},
|
|
})
|
|
}
|