Skip to content

Commit

Permalink
Updated example
Browse files Browse the repository at this point in the history
  • Loading branch information
ankane committed Sep 18, 2023
1 parent 66aba74 commit fc062e1
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions LibPQ/example.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ conn = LibPQ.Connection("dbname=pgvector_julia_test host=localhost")

execute(conn, "CREATE EXTENSION IF NOT EXISTS vector")
execute(conn, "DROP TABLE IF EXISTS items")
execute(conn, "CREATE TABLE items (embedding vector(3))")
execute(conn, "CREATE TABLE items (id bigserial PRIMARY KEY, embedding vector(3))")

module Pgvector
convert(v::AbstractVector{T}) where T<:Real = string("[", join(v, ","), "]")
Expand All @@ -24,6 +24,6 @@ result = execute(conn, "SELECT * FROM items ORDER BY embedding <-> \$1 LIMIT 5",
data = columntable(result)
println(map(Pgvector.parse, data.embedding))

execute(conn, "CREATE INDEX my_index ON items USING ivfflat (embedding vector_l2_ops)")
execute(conn, "CREATE INDEX ON items USING hnsw (embedding vector_l2_ops)")

close(conn)
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ execute(conn, "CREATE EXTENSION IF NOT EXISTS vector")
Create a table

```julia
execute(conn, "CREATE TABLE items (embedding vector(3))")
execute(conn, "CREATE TABLE items (id bigserial PRIMARY KEY, embedding vector(3))")
```

Insert vectors
Expand Down

0 comments on commit fc062e1

Please sign in to comment.