Cross table similarity
cross_table_similarityFind rows in one table most similar to a specific row in another table using vector embeddings, for entity resolution and cross-table linking.
Instructions
Find the k rows in target_schema.target_table most similar to a specific row in source_schema.source_table. Locates the source row via source_id_column = source_id_value, reads its embedding from source_embedding_column, then issues a pgvector k-NN query against target_embedding_column. Both columns must be vector(N) of the same N — verified from the catalog up front so a mismatch fails with a clear error rather than a cast error. Useful for entity-resolution / linking across tables whose embeddings come from different models but share a dimension. Returns source_embedding_found=false when no row matches the id value. Reports available=false if pgvector is not installed.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| k | No | ||
| metric | No | l2 | |
| database | No | Optional: target a configured secondary (read-only) database by name; omit for the primary. Call list_databases to see the configured ids. | |
| source_table | Yes | ||
| target_table | Yes | ||
| source_schema | Yes | ||
| target_schema | Yes | ||
| source_id_value | Yes | ||
| source_id_column | Yes | ||
| source_embedding_column | Yes | ||
| target_embedding_column | Yes |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| matches | Yes | ||
| available | Yes | ||
| source_dimension | Yes | ||
| source_embedding_found | Yes |