-
Notifications
You must be signed in to change notification settings - Fork 1
/
delete.go
36 lines (29 loc) · 1.07 KB
/
delete.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
package vector
const deletePath = "/delete"
// Delete deletes the vector with the given id in the default namespace and reports whether the vector is deleted.
// If a vector with the given id is not found, Delete returns false.
func (ix *Index) Delete(id string) (ok bool, err error) {
return ix.deleteInternal(id, defaultNamespace)
}
// DeleteMany deletes the vectors with the given ids in the default namespace and reports how many of them are deleted.
func (ix *Index) DeleteMany(ids []string) (count int, err error) {
return ix.deleteManyInternal(ids, defaultNamespace)
}
func (ix *Index) deleteInternal(id string, ns string) (ok bool, err error) {
data, err := ix.sendBytes(buildPath(deletePath, ns), []byte(id))
if err != nil {
return
}
deleted, err := parseResponse[deleted](data)
ok = deleted.Deleted != 0
return
}
func (ix *Index) deleteManyInternal(ids []string, ns string) (count int, err error) {
data, err := ix.sendJson(buildPath(deletePath, ns), ids)
if err != nil {
return
}
deleted, err := parseResponse[deleted](data)
count = deleted.Deleted
return
}