Skip to content

Commit 3bb2bf5

Browse files
committed
Improved example
1 parent c32dd6c commit 3bb2bf5

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

test/example.lua

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,15 @@ assert(pg:query("DROP TABLE IF EXISTS items"))
1212

1313
assert(pg:query("CREATE TABLE items (id bigserial PRIMARY KEY, embedding vector(3))"))
1414

15-
embedding1 = pgvector.new({1, 1, 1})
16-
embedding2 = pgvector.new({2, 2, 2})
17-
embedding3 = pgvector.new({1, 1, 2})
15+
local embedding1 = pgvector.new({1, 1, 1})
16+
local embedding2 = pgvector.new({2, 2, 2})
17+
local embedding3 = pgvector.new({1, 1, 2})
1818
assert(pg:query("INSERT INTO items (embedding) VALUES ($1), ($2), ($3)", embedding1, embedding2, embedding3))
1919

2020
-- optional: automatically convert vector type to table
2121
-- pgvector.setup_vector(pg)
2222

23-
embedding = pgvector.new({1, 1, 1})
23+
local embedding = pgvector.new({1, 1, 1})
2424
local res = assert(pg:query("SELECT * FROM items ORDER BY embedding <-> $1 LIMIT 5", embedding))
2525
for i, row in ipairs(res) do
2626
for k, v in pairs(row) do

0 commit comments

Comments
 (0)