-
Notifications
You must be signed in to change notification settings - Fork 1
/
upsert.go
33 lines (28 loc) · 954 Bytes
/
upsert.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
package vector
const upsertPath = "/upsert"
// Upsert updates or inserts a vector to the default namespace of the index.
// Additional metadata can also be provided while upserting the vector.
func (ix *Index) Upsert(u Upsert) (err error) {
return ix.upsertInternal(u, defaultNamespace)
}
// UpsertMany updates or inserts some vectors to the default namespace of the index.
// Additional metadata can also be provided for each vector.
func (ix *Index) UpsertMany(u []Upsert) (err error) {
return ix.upsertManyInternal(u, defaultNamespace)
}
func (ix *Index) upsertInternal(u Upsert, ns string) (err error) {
data, err := ix.sendJson(buildPath(upsertPath, ns), u)
if err != nil {
return
}
_, err = parseResponse[string](data)
return
}
func (ix *Index) upsertManyInternal(u []Upsert, ns string) (err error) {
data, err := ix.sendJson(buildPath(upsertPath, ns), u)
if err != nil {
return
}
_, err = parseResponse[string](data)
return
}