@@ -117,8 +117,9 @@ query like this:
117
117
``` sql
118
118
SELECT ai .create_vectorizer (
119
119
' blog' ::regclass,
120
+ name => ' blog_embeddings' , -- Optional custom name for easier reference
120
121
loading => ai .loading_column (' contents' ),
121
- destination => ' blog_contents_embeddings' ,
122
+ destination => ai . destination_table ( ' blog_contents_embeddings' ) ,
122
123
embedding => ai .embedding_ollama (' nomic-embed-text' , 768 )
123
124
);
124
125
```
@@ -150,7 +151,7 @@ into each chunk:
150
151
SELECT ai .create_vectorizer (
151
152
' blog' ::regclass,
152
153
loading => ai .loading_column (' contents' ),
153
- destination => ' blog_contents_embeddings' ,
154
+ destination => ai . destionation ( ' blog_contents_embeddings' ) ,
154
155
embedding => ai .embedding_ollama (' nomic-embed-text' , 768 ),
155
156
formatting => ai .formatting_python_template (' $title: $chunk' )
156
157
);
@@ -284,7 +285,7 @@ accordingly:
284
285
SELECT ai .create_vectorizer (
285
286
' blog' ::regclass,
286
287
loading => ai .loading_column (' contents' ),
287
- destination => ' blog_contents_embeddings' ,
288
+ destination => ai . destination ( ' blog_contents_embeddings' ) ,
288
289
embedding => ai .embedding_ollama (' nomic-embed-text' , 768 ),
289
290
formatting => ai .formatting_python_template (' $title - by $author - $chunk' )
290
291
);
@@ -304,7 +305,7 @@ example uses a HNSW index:
304
305
SELECT ai .create_vectorizer (
305
306
' blog' ::regclass,
306
307
loading => ai .loading_column (' contents' ),
307
- destination => ' blog_contents_embeddings' ,
308
+ destination => ai . destination ( ' blog_contents_embeddings' ) ,
308
309
embedding => ai .embedding_ollama (' nomic-embed-text' , 768 ),
309
310
formatting => ai .formatting_python_template (' $title - by $author - $chunk' ),
310
311
indexing => ai .indexing_hnsw (min_rows => 100000 , opclass => ' vector_l2_ops' )
@@ -344,6 +345,56 @@ CREATE TABLE blog_contents_embeddings_store(
344
345
);
345
346
```
346
347
348
+ ## Destination Options for Embeddings
349
+
350
+ Vectorizer supports two different ways to store your embeddings:
351
+
352
+ ### 1. Table Destination (Default)
353
+
354
+ The default approach creates a separate table to store embeddings and a view that joins with the source table:
355
+
356
+ ``` sql
357
+ SELECT ai .create_vectorizer (
358
+ ' blog' ::regclass,
359
+ name => ' blog_vectorizer' , -- Optional custom name for easier reference
360
+ loading => ai .loading_column (' contents' ),
361
+ destination => ai .destination_table (
362
+ target_schema => ' public' ,
363
+ target_table => ' blog_embeddings_store' ,
364
+ view_name => ' blog_embeddings'
365
+ ),
366
+ embedding => ai .embedding_ollama (' nomic-embed-text' , 768 )
367
+ );
368
+ ```
369
+
370
+ ** When to use table destination:**
371
+ - When you need multiple embeddings per row (chunking)
372
+ - For large text fields that need to be split
373
+ - You are vectorizing documents (which typically require chunking)
374
+
375
+ ### 2. Column Destination
376
+
377
+ For simpler cases, you can add an embedding column directly to the source table:
378
+
379
+ ``` sql
380
+ SELECT ai .create_vectorizer (
381
+ ' product_descriptions' ::regclass,
382
+ name => ' product_descriptions_vectorizer' ,
383
+ loading => ai .loading_column (' description' ),
384
+ destination => ai .destination_column (' description_embedding' ),
385
+ embedding => ai .embedding_openai (' text-embedding-3-small' , 768 ),
386
+ chunking => ai .chunking_none () -- Required for column destination
387
+ );
388
+ ```
389
+
390
+ ** When to use column destination:**
391
+ - When you need exactly one embedding per row
392
+ - For shorter text that doesn't require chunking
393
+ - When your application already takes care of the chunking before inserting into the database
394
+ - When you want to avoid creating additional database objects
395
+
396
+ ** Note:** Column destination requires chunking to be set to ` ai.chunking_none() ` since it can only store one embedding per row.
397
+
347
398
## Monitor a vectorizer
348
399
349
400
Since embeddings are created asynchronously, a delay may occur before they
0 commit comments