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

Function TestVectorReindex

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

Source from the content-addressed store, hash-verified

585}
586
587func TestVectorReindex(t *testing.T) {
588 dropPredicate("vtest")
589
590 pred := "vtest"
591
592 setSchema(fmt.Sprintf(vectorSchemaWithIndex, pred, "4", "euclidean"))
593
594 numVectors := 100
595 vectorSize := 4
596
597 randomVectors, allVectors := generateRandomVectors(numVectors, vectorSize, pred)
598 require.NoError(t, addTriplesToCluster(randomVectors))
599
600 setSchema(fmt.Sprintf(vectorSchemaWithoutIndex, pred))
601
602 query := `{
603 vector(func: has(vtest)) {
604 count(uid)
605 }
606 }`
607
608 result := processQueryNoErr(t, query)
609 require.JSONEq(t, `{"data": {"vector":[{"count":100}]}}`, result)
610
611 triple := strings.Split(randomVectors, "\n")[0]
612 _, err := querySingleVectorError(t, strings.Split(triple, `"`)[1], "vtest", false)
613 require.NotNil(t, err)
614
615 setSchema(fmt.Sprintf(vectorSchemaWithIndex, pred, "4", "euclidean"))
616 vector, err := querySingleVector(t, strings.Split(triple, `"`)[1], "vtest")
617 require.NoError(t, err)
618 require.Contains(t, allVectors, vector)
619}
620
621func TestVectorMutationWithoutIndex(t *testing.T) {
622 dropPredicate("vtest")

Callers

nothing calls this directly

Calls 7

generateRandomVectorsFunction · 0.85
querySingleVectorErrorFunction · 0.85
querySingleVectorFunction · 0.85
dropPredicateFunction · 0.70
setSchemaFunction · 0.70
addTriplesToClusterFunction · 0.70
processQueryNoErrFunction · 0.70

Tested by

no test coverage detected