Here’s a quick tip for anyone tinkering with vectors and vector indexes in 23ai. Let’s say you have just created a vector index on your table as per below
SQL> create vector index DOC_CHUNKS_VEC_IX on DOC_CHUNKS(piece_embed)
2 organization INMEMORY NEIGHBOR GRAPH
3 distance COSINE
4 with target accuracy 95;
Index created.
and now you would like to grab the DDL for that index. You fire up your trusty DBMS_METADATA script and …. hmmmmm
SQL> select dbms_metadata.get_ddl('INDEX','DOC_CHUNKS_VEC_IX') from dual;
DBMS_METADATA.GET_DDL('INDEX','DOC_CHUNKS_VEC_IX')
--------------------------------------------------------------------------------
CREATE INDEX "CONNOR"."DOC_CHUNKS_VEC_IX" ON "MCDONAC"."DOC_CHUNKS" ("PIECE_EMBED")
This is because the object you have created is not an index, it is a vector index. You need to adjust the object type that you pass in.
SQL> select dbms_metadata.get_ddl('VECTOR_INDEX','DOC_CHUNKS_VEC_IX') from dual;
DBMS_METADATA.GET_DDL('VECTOR_INDEX','DOC_CHUNKS_VEC_IX')
--------------------------------------------------------------------------------
CREATE VECTOR INDEX "CONNOR"."DOC_CHUNKS_VEC_IX" ON "CONNOR"."DOC_CHUNKS" ("PIECE_EMBED")
ORGANIZATION INMEMORY NEIGHBOR GRAPH
WITH DISTANCE COSINE WITH TARGET ACCURACY 95
PARAMETERS (TYPE HNSW, NEIGHBORS 32, EFCONSTRUCTION 300) PARALLEL 1
Officially this is not a bug in DBMS_METADATA, but it is likely that we’ll make a tweak to the API to return an error if you pass in INDEX for a vector index just so there is no chance of confusion.
Been playing with vectors? Let me know in the comments how you’re going.




Leave a reply to isdba39bfa2f000 Cancel reply