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

Function queryVectorUsingUid

query/vector/vector_test.go:164–192  ·  view source on GitHub ↗
(t *testing.T, uid, pred string)

Source from the content-addressed store, hash-verified

162}
163
164func queryVectorUsingUid(t *testing.T, uid, pred string) ([]float32, error) {
165 vectorQuery := fmt.Sprintf(`
166 {
167 vector(func: uid(%v)) {
168 %v
169 }
170 }`, uid, pred)
171
172 resp, err := client.Query(vectorQuery)
173 require.NoError(t, err)
174
175 type VectorData struct {
176 VTest []float32 `json:"vtest"`
177 }
178
179 type Data struct {
180 Vector []VectorData `json:"vector"`
181 }
182
183 var data Data
184
185 err = json.Unmarshal([]byte(resp.Json), &data)
186 if err != nil {
187 return []float32{}, err
188 }
189
190 return data.Vector[0].VTest, nil
191
192}
193
194func queryMultipleVectorsUsingSimilarTo(t *testing.T, vector []float32, pred string, topK int) ([][]float32, error) {
195 vectorQuery := fmt.Sprintf(`

Callers 1

updateVectorFunction · 0.85

Calls 1

QueryMethod · 0.45

Tested by

no test coverage detected