-
Notifications
You must be signed in to change notification settings - Fork 1
/
query_data.go
22 lines (19 loc) · 941 Bytes
/
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
package vector
const queryDataPath = "/query-data"
// QueryData returns the result of the query for the given data by converting it to an embedding on the server.
// When q.TopK is specified, the result will contain at most q.TopK many vectors.
// The returned list will contain vectors sorted in descending order of score,
// which correlates with the similarity of the vectors to the given query vector.
// When q.IncludeVectors is true, values of the vectors are also returned.
// When q.IncludeMetadata is true, metadata of the vectors are also returned, if any.
func (ix *Index) QueryData(q QueryData) (scores []VectorScore, err error) {
return ix.queryDataInternal(q, defaultNamespace)
}
func (ix *Index) queryDataInternal(q QueryData, ns string) (scores []VectorScore, err error) {
data, err := ix.sendJson(buildPath(queryDataPath, ns), q)
if err != nil {
return
}
scores, err = parseResponse[[]VectorScore](data)
return
}