-
-
Save felixhummel/ee15c4eca9c3d17066ab30aa174d61c6 to your computer and use it in GitHub Desktop.
postgres json --> array --> pgvector
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
postgres=# CREATE TABLE x AS SELECT '{"foo": 1, "bar": 2}'::jsonb AS payload; | |
SELECT 1 | |
postgres=# SELECT * FROM x; | |
payload | |
---------------------- | |
{"bar": 2, "foo": 1} | |
(1 row) | |
postgres=# SELECT ARRAY[payload->'foo', payload->'bar']::float[]::vector FROM x; | |
array | |
------- | |
[1,2] | |
(1 row) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment