Skip to content

Commit 5c23d24

Browse files
committed
Vector index test
1 parent af5df4d commit 5c23d24

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

src/test/11-managing-indexes.ts

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { Database } from "../databases.js";
44
import { config } from "./_config.js";
55

66
const it312 = config.arangoVersion! >= 31200 ? it : it.skip;
7+
const it31205 = config.arangoVersion! >= 31205 ? it : it.skip;
78

89
describe("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

Comments
 (0)