@@ -4,6 +4,7 @@ import { Database } from "../databases.js";
44import { config } from "./_config.js" ;
55
66const it312 = config . arangoVersion ! >= 31200 ? it : it . skip ;
7+ const it31205 = config . arangoVersion ! >= 31205 ? it : it . skip ;
78
89describe ( "Managing indexes" , function ( ) {
910 let system : Database , db : Database ;
@@ -80,6 +81,35 @@ describe("Managing indexes", function () {
8081 expect ( info ) . to . have . property ( "isNewlyCreated" , true ) ;
8182 } ) ;
8283 } ) ;
84+ describe ( "collection.ensureIndex#vector" , ( ) => {
85+ it31205 ( "should create a vector index" , async ( ) => {
86+ await collection . save ( {
87+ _key : "sample1" ,
88+ embedding : Array ( 128 ) . fill ( 0.1 ) ,
89+ } ) ;
90+ await collection . save ( {
91+ _key : "sample2" ,
92+ embedding : Array ( 128 ) . fill ( 0.1 ) ,
93+ } ) ;
94+ const info = await collection . ensureIndex ( {
95+ type : "vector" ,
96+ fields : [ "embedding" ] ,
97+ params : {
98+ metric : "cosine" ,
99+ dimension : 128 ,
100+ nLists : 2 ,
101+ } ,
102+ } ) ;
103+ expect ( info ) . to . have . property ( "id" ) ;
104+ expect ( info ) . to . have . property ( "type" , "vector" ) ;
105+ expect ( info ) . to . have . property ( "fields" ) ;
106+ expect ( info . fields ) . to . eql ( [ "embedding" ] ) ;
107+ expect ( info ) . to . have . property ( "isNewlyCreated" , true ) ;
108+ expect ( info ) . to . have . nested . property ( "params.metric" , "cosine" ) ;
109+ expect ( info ) . to . have . nested . property ( "params.dimension" , 128 ) ;
110+ expect ( info ) . to . have . nested . property ( "params.nLists" , 2 ) ;
111+ } ) ;
112+ } ) ;
83113 describe ( "collection.index" , ( ) => {
84114 it ( "should return information about a index" , async ( ) => {
85115 const info = await collection . ensureIndex ( {
0 commit comments