@@ -18,7 +18,7 @@ import (
1818 testUtils "github.com/sourcenetwork/defradb/tests/integration"
1919)
2020
21- // A _similarity + order DESC + limit query on a ready @vectorIndex returns the k nearest documents
21+ // A _similarity + order DESC + limit query on a ready @index(vector: {...}) returns the k nearest documents
2222// (nearest to [1,0,0] is "x", then "xy") and reads only those k, not the whole collection. The
2323// explain variant asserts two doc fetches (a full scan would read four).
2424func TestQuerySimple_WithSimilarityOnVectorIndex_ReturnsKNearest (t * testing.T ) {
@@ -27,7 +27,7 @@ func TestQuerySimple_WithSimilarityOnVectorIndex_ReturnsKNearest(t *testing.T) {
2727 & action.AddCollection {
2828 SDL : `type User {
2929 name: String
30- vector: [Float32!] @vectorIndex( dimensions: 3, HNSW : {metric: COSINE})
30+ vector: [Float32!] @index(vector: { dimensions: 3, hnsw : {metric: COSINE} })
3131 }` ,
3232 },
3333 & action.AddDoc {DocMap : map [string ]any {"name" : "x" , "vector" : []float32 {1 , 0 , 0 }}},
@@ -72,7 +72,7 @@ func TestQuerySimple_WithSimilarityOnVectorIndex_ReflectsUpdatedVector(t *testin
7272 & action.AddCollection {
7373 SDL : `type User {
7474 name: String
75- vector: [Float32!] @vectorIndex( dimensions: 3, HNSW : {metric: COSINE})
75+ vector: [Float32!] @index(vector: { dimensions: 3, hnsw : {metric: COSINE} })
7676 }` ,
7777 },
7878 // a sits off the query axis; b starts even further off. After the update b lands exactly on
@@ -113,7 +113,7 @@ func TestQuerySimple_WithSimilarityOnVectorIndex_ExcludesDeletedDoc(t *testing.T
113113 & action.AddCollection {
114114 SDL : `type User {
115115 name: String
116- vector: [Float32!] @vectorIndex( dimensions: 3, HNSW : {metric: COSINE})
116+ vector: [Float32!] @index(vector: { dimensions: 3, hnsw : {metric: COSINE} })
117117 }` ,
118118 },
119119 // x is nearest to the query [1,0,0], xy is second nearest.
@@ -151,7 +151,7 @@ func TestQuerySimple_WithSimilarityOnVectorIndex_IsMagnitudeInvariant(t *testing
151151 & action.AddCollection {
152152 SDL : `type User {
153153 name: String
154- vector: [Float32!] @vectorIndex( dimensions: 3, HNSW : {metric: COSINE})
154+ vector: [Float32!] @index(vector: { dimensions: 3, hnsw : {metric: COSINE} })
155155 }` ,
156156 },
157157 & action.AddDoc {DocMap : map [string ]any {"name" : "unit" , "vector" : []float32 {1 , 0 , 0 }}},
@@ -193,7 +193,7 @@ func TestQuerySimple_WithSimilarityOnVectorIndex_AscendingOrderFullScans(t *test
193193 & action.AddCollection {
194194 SDL : `type User {
195195 name: String
196- vector: [Float32!] @vectorIndex( dimensions: 3, HNSW : {metric: COSINE})
196+ vector: [Float32!] @index(vector: { dimensions: 3, hnsw : {metric: COSINE} })
197197 }` ,
198198 },
199199 }, append (docs ,
@@ -235,7 +235,7 @@ func TestQuerySimple_WithSimilarityOnVectorIndex_RespectsOffset(t *testing.T) {
235235 & action.AddCollection {
236236 SDL : `type User {
237237 name: String
238- vector: [Float32!] @vectorIndex( dimensions: 3, HNSW : {metric: COSINE})
238+ vector: [Float32!] @index(vector: { dimensions: 3, hnsw : {metric: COSINE} })
239239 }` ,
240240 },
241241 & action.AddDoc {DocMap : map [string ]any {"name" : "x" , "vector" : []float32 {1 , 0 , 0 }}},
@@ -270,7 +270,7 @@ func TestQuerySimple_WithSimilarityOnVectorIndex_WrongLengthQueryErrors(t *testi
270270 & action.AddCollection {
271271 SDL : `type User {
272272 name: String
273- vector: [Float32!] @vectorIndex( dimensions: 3, HNSW : {metric: COSINE})
273+ vector: [Float32!] @index(vector: { dimensions: 3, hnsw : {metric: COSINE} })
274274 }` ,
275275 },
276276 & action.AddDoc {DocMap : map [string ]any {"name" : "x" , "vector" : []float32 {1 , 0 , 0 }}},
@@ -299,7 +299,7 @@ func TestQuerySimple_WithSimilarityOnVectorIndex_NoOrderDoesNotUseIndex(t *testi
299299 & action.AddCollection {
300300 SDL : `type User {
301301 name: String
302- vector: [Float32!] @vectorIndex( dimensions: 3, HNSW : {metric: COSINE})
302+ vector: [Float32!] @index(vector: { dimensions: 3, hnsw : {metric: COSINE} })
303303 }` ,
304304 },
305305 & action.AddDoc {DocMap : map [string ]any {"name" : "x" , "vector" : []float32 {1 , 0 , 0 }}},
0 commit comments