MCPcopy Index your code
hub / github.com/dgraph-io/dgraph / queryMultipleVectorsUsingSimilarTo

Function queryMultipleVectorsUsingSimilarTo

query/vector/vector_test.go:194–227  ·  view source on GitHub ↗
(t *testing.T, vector []float32, pred string, topK int)

Source from the content-addressed store, hash-verified

192}
193
194func queryMultipleVectorsUsingSimilarTo(t *testing.T, vector []float32, pred string, topK int) ([][]float32, error) {
195 vectorQuery := fmt.Sprintf(`
196 {
197 vector(func: similar_to(%v, %v, "%v")) {
198 uid
199 %v
200 }
201 }`, pred, topK, vector, pred)
202
203 resp, err := client.Query(vectorQuery)
204 require.NoError(t, err)
205
206 type VectorData struct {
207 UID string `json:"uid"`
208 VTest []float32 `json:"vtest"`
209 }
210
211 type Data struct {
212 Vector []VectorData `json:"vector"`
213 }
214
215 var data Data
216
217 err = json.Unmarshal([]byte(resp.Json), &data)
218 if err != nil {
219 return [][]float32{}, err
220 }
221
222 var vectors [][]float32
223 for _, vector := range data.Vector {
224 vectors = append(vectors, vector.VTest)
225 }
226 return vectors, nil
227}
228
229func querySingleVectorError(t *testing.T, vector, pred string, validateError bool) ([]float32, error) {
230

Callers 2

TestVectorUpdateFunction · 0.85

Calls 1

QueryMethod · 0.45

Tested by

no test coverage detected