Skip to content

How to Create a Vector-Powered Search Layer on Top of Your PostgreSQL Data

Arrow down icon
How to Create a Vector-Powered Search Layer on Top of Your PostgreSQL Data
How to Create a Vector-Powered Search Layer on Top of Your PostgreSQL Data

Most enterprise data already lives in structured systems like PostgreSQL. The challenge is not access, it is making that data usable for AI.

Search today is no longer just keyword matching. Teams need semantic search: the ability to find meaning, not just exact text. This requires transforming structured records into embeddings and storing them in a way AI systems can query in real time.

This guide shows how to do exactly that using AISquared’s UNIFI platform. You will learn how to connect your PostgreSQL database, prepare your data, and sync it into the AISquared Vector Store to enable semantic search across your records.

The goal is simple: take existing data and make it ready for AI-driven applications without rebuilding your systems.

Overview

This workflow covers how to connect a PostgreSQL database as a source, define a vector store destination in UNIFI, build a data model over your Postgres data, and run a sync that writes embeddings and metadata into the AISquared Vector Store.

Use case: Structured drug records stored in PostgreSQL are modeled, embedded, and synced into the AISquared Vector Store — enabling semantic similarity search over prescription drug data within UNIFI-powered applications.

Step 1 — Configure the PostgreSQL Source

In UNIFI: Sources → New Source → PostgreSQL

Add your PostgreSQL database as a source using standard connection credentials. The user must have at minimum SELECT access on the tables you intend to query.

FieldValueNotes
auth_typeusername/passwordStandard Postgres credential auth
Usernamee.g. davidtestdb_userMust have SELECT on target tables
Password(your password)Stored encrypted by UNIFI
Hoste.g. a.oregon-postgres.render.comHostname or IP of your Postgres server
Port5432Default Postgres port
Databasee.g. davidtestdbName of the database to connect to
Schemae.g. publicSchema containing the tables to sync from

Step 2 — Configure the AISquared Vector Store Destination

In UNIFI: Destinations → New Destination → AISquared Vector Store

The AISquared Vector Store is UNIFI’s native managed vector database. After creating the destination, define a table to hold your embeddings and metadata.

2.1  Create a Table

Once the destination is saved, click into it and select Create Table. Define your table name and columns using the schema editor:

Column NameData TypeConstraintsNotes
idint8Primary KeyAuto-incrementing row identifier
drug_idtextNULLSource identifier for the record
drug_nametextNULLHuman-readable name for display/search
embeddingvectorNULLThe generated embedding vector
created_attimestampNULLRecord creation time
embedding_texttextNULLRaw text that was embedded
embedding_typetextNULLEmbedding model or type label
Note: If the table is part of an active sync it cannot be modified. Disable the sync first before editing the schema, then re-enable it after saving.

Step 3 — Create the Data Model

In UNIFI: Models → Add Model → select your PostgreSQL source

The data model defines how UNIFI reads and prepares data from your Postgres source before syncing it to the vector store. Configure it using one of the three retrieval methods below.

3.1  Data Retrieval Method

Choose one of the following methods when setting up the model:

MethodDescriptionBest For
Table SelectionBrowse and select a table directly from the source schemaSimple full-table syncs with no transformation needed
Static QueryWrite a fixed SQL SELECT statement executed on every sync runFiltered or joined datasets that don’t change structure
Dynamic QueryParameterized SQL that can incorporate runtime variablesIncremental or time-windowed queries

3.2  Preview and Finalize

  1. After configuring your retrieval method, click Show Preview to confirm the query returns the expected rows and column structure
  2. Verify the output contains the columns you intend to map (e.g. drug_id, drug_name, embedding_text)
  3. Give the model a descriptive name and click Continue to save it
Tip: Always use Show Preview before saving the model. A missing column at this stage will cause mapping errors later in the sync configuration and require you to recreate the model.

Step 4 — Create and Run the Sync

In UNIFI: Syncs → New Sync → select your data model → select your AISquared Vector Store destination

4.1  Sync Configuration Steps

  1. Select the data model created in Step 3 as the sync source
  2. Select the AISquared Vector Store destination configured in Step 2
  3. In the Stream Name dropdown, select your target vector table (e.g. prescription_drugs_synthetic_vector_db). If it does not appear, click Refresh to reload the destination catalog
  4. Set Sync Mode to Incremental to process only new or updated records on each run
  5. Map each PostgreSQL source field to the corresponding AISquared Vector Store column (see field mapping table below). For the embedding field, select the appropriate embedding model or check Skip embedding configuration when both fields are vector types if the source already contains pre-computed vectors
  6. Configure the sync schedule — choose from Manual, Interval (e.g. every N hours), or Cron Expression for fine-grained control
  7. Click Save Changes to persist the sync configuration
  8. Click Run Now to execute the sync. Monitor progress under the Sync Runs tab
Tip: Some model types support a Test Sync button, which processes a single row and returns enhanced debugging output. Use this to validate your field mappings and embedding configuration before running a full sync.

4.2  Field Mapping Reference

PostgreSQL Field (Source)Vector Store Column (Destination)Notes
idid
drug_namedrug_name
embedding_textembedding_textText used for embedding generation
embeddingembeddingSkip config if both are vector type
embedding_typeembedding_type
drug_iddrug_id

4.3  Scheduling Options

ModeConfigurationUse When
ManualTriggered via Run Now button onlyAd-hoc loads or initial data validation
IntervalSet a frequency in minutes or hoursRegular recurring syncs without precise timing needs
Cron ExpressionStandard cron syntax, e.g. 0 2 * * *Precise scheduled windows, e.g. nightly at 2 AM

Quick Reference — Workflow Summary

StepActionKey Detail
1Create PostgreSQL Sourceusername/password auth; user needs SELECT on target tables; specify schema
2Create Vector Store DestinationAdd table with id (int8 PK), drug_id, drug_name, embedding (vector), embedding_text, embedding_type, created_at
3Create Data ModelChoose Table Selection, Static Query, or Dynamic Query; always Show Preview before saving
4Create & Run SyncMap 6 fields; Incremental mode; select embedding model or skip for pre-computed vectors; set schedule; Save + Run Now

Measure Your AI Readiness

See where your organization stands today across data, security, governance, workflows, adoption, and improvement.