-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathresumable_query_data.go
31 lines (26 loc) · 1.03 KB
/
resumable_query_data.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
package vector
const resumableQueryDataPath = "/resumable-query-data"
// ResumableQueryData starts a resumable query and returns the first page of the
// result of the query for the given text data in the default namespace.
// Then, next pages of the query results can be fetched over the returned handle.
// After all the needed pages of the results are fetched, it is recommended
// to close to handle to release the acquired resources.
func (ix *Index) ResumableQueryData(q ResumableQueryData) (scores []VectorScore, handle *ResumableQueryHandle, err error) {
return ix.resumableQueryDataInternal(q, defaultNamespace)
}
func (ix *Index) resumableQueryDataInternal(q ResumableQueryData, ns string) (scores []VectorScore, handle *ResumableQueryHandle, err error) {
data, err := ix.sendJson(buildPath(resumableQueryDataPath, ns), q)
if err != nil {
return
}
start, err := parseResponse[resumableQueryStart](data)
if err != nil {
return
}
scores = start.Scores
handle = &ResumableQueryHandle{
index: ix,
uuid: start.UUID,
}
return
}