MCPcopy
hub / github.com/dgraph-io/dgraph / TestVectorInQueryArgument

Function TestVectorInQueryArgument

query/vector/vector_test.go:488–511  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

486}
487
488func TestVectorInQueryArgument(t *testing.T) {
489 dropPredicate("vtest")
490 setSchema(fmt.Sprintf(vectorSchemaWithIndex, "vtest", "4", "euclidean"))
491
492 numVectors := 100
493 vectorSize := 4
494
495 randomVectors, allVectors := generateRandomVectors(numVectors, vectorSize, "vtest")
496 require.NoError(t, addTriplesToCluster(randomVectors))
497
498 query := `query demo($v: float32vector) {
499 vector(func: similar_to(vtest, 1, $v)) {
500 uid
501 }
502 }`
503
504 vectorString := fmt.Sprintf(`[%s]`, strings.Trim(strings.Join(strings.Fields(fmt.Sprint(allVectors[0])), ", "), "[]"))
505 vars := map[string]string{
506 "$v": vectorString,
507 }
508
509 _, err := processQueryWithVars(t, query, vars)
510 require.NoError(t, err)
511}
512
513func TestVectorsMutateFixedLengthWithDiffrentIndexes(t *testing.T) {
514 dropPredicate("vtest")

Callers

nothing calls this directly

Calls 6

generateRandomVectorsFunction · 0.85
dropPredicateFunction · 0.70
setSchemaFunction · 0.70
addTriplesToClusterFunction · 0.70
processQueryWithVarsFunction · 0.70
FieldsMethod · 0.65

Tested by

no test coverage detected