Home / Function/ pgSuite.vectorIndex() — drizzle-orm Function Reference

pgSuite.vectorIndex() — drizzle-orm Function Reference

Architecture documentation for the pgSuite.vectorIndex() function in pg.test.ts from the drizzle-orm codebase.

Entity Profile

Dependency Diagram

graph TD
  6196f8a7_8d5b_03e5_b99e_f765f34dae2b["pgSuite.vectorIndex()"]
  66244d8b_f6c8_7e4e_5409_4e7e6a4add95["pg.test.ts"]
  6196f8a7_8d5b_03e5_b99e_f765f34dae2b -->|defined in| 66244d8b_f6c8_7e4e_5409_4e7e6a4add95
  style 6196f8a7_8d5b_03e5_b99e_f765f34dae2b fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

drizzle-kit/tests/indexes/pg.test.ts lines 10–69

	async vectorIndex() {
		const schema1 = {
			users: pgTable('users', {
				id: serial('id').primaryKey(),
				name: vector('name', { dimensions: 3 }),
			}),
		};

		const schema2 = {
			users: pgTable(
				'users',
				{
					id: serial('id').primaryKey(),
					embedding: vector('name', { dimensions: 3 }),
				},
				(t) => ({
					indx2: index('vector_embedding_idx')
						.using('hnsw', t.embedding.op('vector_ip_ops'))
						.with({ m: 16, ef_construction: 64 }),
				}),
			),
		};

		const { statements, sqlStatements } = await diffTestSchemas(
			schema1,
			schema2,
			[],
		);

		expect(statements.length).toBe(1);
		expect(statements[0]).toStrictEqual({
			schema: '',
			tableName: 'users',
			type: 'create_index_pg',
			data: {
				columns: [
					{
						asc: true,
						expression: 'name',
						isExpression: false,
						nulls: 'last',
						opclass: 'vector_ip_ops',
					},
				],
				concurrently: false,
				isUnique: false,
				method: 'hnsw',
				name: 'vector_embedding_idx',
				where: undefined,
				with: {
					ef_construction: 64,
					m: 16,
				},
			},
		});
		expect(sqlStatements.length).toBe(1);
		expect(sqlStatements[0]).toBe(
			`CREATE INDEX "vector_embedding_idx" ON "users" USING hnsw ("name" vector_ip_ops) WITH (m=16,ef_construction=64);`,
		);
	},

Domain

Subdomains

Frequently Asked Questions

What does pgSuite.vectorIndex() do?
pgSuite.vectorIndex() is a function in the drizzle-orm codebase, defined in drizzle-kit/tests/indexes/pg.test.ts.
Where is pgSuite.vectorIndex() defined?
pgSuite.vectorIndex() is defined in drizzle-kit/tests/indexes/pg.test.ts at line 10.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free