Build a Semantic Search Page in Oracle APEX with AI Vector Search (No External AI)

Oracle APEX AI Vector Search Hybrid Search Series Part 3

Build a Semantic Search Page in Oracle APEX with AI Vector Search (No External AI)

Users type what they mean in their own words, and the APEX page finds the right record. A search page with a match score, a minimum match, a keyword boost for error codes and a vector index for large tables. All inside the Oracle database, tested for real.

📅 October 2026 👤 Sajjad Hanifa ⏱ ~18 min read 🏢 S&H Software Solutions

Every APEX application I have built has a search field somewhere. And almost every one of them works the same way. LIKE '%' || :P1_SEARCH || '%', maybe with UPPER around it. It finds what users type, letter for letter. It does not find what they mean.

A user writes "people keep getting kicked out of the app". The task in the system is called "Users get logged out after a few minutes". Not one word in common that matters. LIKE finds nothing, and the user creates a duplicate task.

In part 2 the database got its own embedding model. Today I build the real thing on top of it. A Smart Search page in the Task Board app, the SQL behind it, the fine tuning that makes it usable, and a vector index for when the table gets big. Six real errors included.

Search your APEX app by meaning. A Smart Search page in Oracle APEX with AI Vector Search
The Smart Search page in the Task Board app finds Users get logged out after a few minutes
Real runWhere we are heading. "People keep getting kicked out of the app" finds "Users get logged out after a few minutes" with a 38 % match. A LIKE finds nothing.
This is part 3 of 3.

Part 1 installed Oracle AI Database 26ai Free, ORDS and APEX 26.2 in Docker. Part 2 loaded the ONNX embedding model all-MiniLM-L12-v2 into the database and added a vector column with a trigger. This post builds on exactly that state.

What We Build

One new page in the Task Board app from part 1. A text field for the question, a select list for the minimum match, a search button, and a result list ranked by meaning. Behind it is one SQL query. No REST call, no external AI service, no Python. The question is turned into a vector inside the database and compared with the stored vectors of all tasks.

PieceWhat I usedWhy
Search textTitle and description in one vectorShort titles give the model too little context
RankingVECTOR_DISTANCE(..., COSINE), shown as match %Users understand 54 % better than 0.463
Junk filterMinimum match, default 25 %A vector search always returns rows, even for nonsense
Exact termsKeyword bonus (hybrid search)Error codes and product names mean nothing to the model
APEX regionClassic Report with the Media List templateTitle, description, icon and a badge per hit, no extra plug-in
Big tablesIVF or HNSW vector indexFor tens of thousands of rows and more

What You Need

The stack from parts 1 and 2. Oracle AI Database 26ai Free 23.26.3 in Docker, APEX 26.2, the model ALL_MINILM_L12_V2 owned by APEXNOTE_VEC and granted to the APEX schema APEXNOTE, and the DEMO_TASKS table with its TITLE_VEC column and trigger. Parts A and B run without any change to the database configuration. Part C changes one memory parameter and restarts the database container once.

I run every SQL script the same way as before. The file goes into the container and SQL*Plus runs it there.

Shellhow every script runson the server
docker cp script.sql apexnote-db:/tmp/ && \
  docker exec -i apexnote-db sqlplus -l apexnote/<your_schema_password>@//localhost:1521/FREEPDB1 @/tmp/script.sql

Part A. The Search in SQL

Before I touch APEX, the query has to be right. Everything the page does later is in these seven steps.

01
Step one

Check the Starting Point

APEXNOTE · rows, trigger, model · ORA-22849

A quick look at what part 2 left behind. How many tasks, how many of them have a vector, is the trigger enabled, and can this schema see the model. My first query already failed.

SQL01_check-starting-point_FAILED-ora-22849.sqlfails
set lines 140 pages 50
col title format a52
col model format a20
select count(*) as tasks, count(title_vec) as with_vector from demo_tasks;
select trigger_name, status from user_triggers where table_name = 'DEMO_TASKS';
select model_name as model, mining_function, algorithm from all_mining_models where owner = 'APEXNOTE_VEC';
select id, title from demo_tasks order by id fetch first 5 rows only;
OutputSQL*Plusreal run
select count(*) as tasks, count(title_vec) as with_vector from demo_tasks
                                *
ERROR at line 1:
ORA-22849: Type VECTOR is not supported for this function or operator.
SQL01_check-starting-point.sqlas APEXNOTE
set lines 140 pages 50
col title format a52
col model format a20
select count(*) as tasks, count(case when title_vec is not null then 1 end) as with_vector from demo_tasks;
select trigger_name, status from user_triggers where table_name = 'DEMO_TASKS';
select model_name as model, mining_function, algorithm from all_mining_models where owner = 'APEXNOTE_VEC';
select id, title from demo_tasks order by id fetch first 5 rows only;
OutputSQL*Plusreal run
     TASKS WITH_VECTOR
---------- -----------
        11          11

TRIGGER_NAME          STATUS
--------------------- --------
DEMO_TASKS_VEC_BIU    ENABLED

MODEL                MINING_FUNCTION   ALGORITHM
-------------------- ----------------- ----------
ALL_MINILM_L12_V2    EMBEDDING         ONNX
ORA-22849 Type VECTOR is not supported for this function or operator
Real runCOUNT(title_vec) raises ORA-22849. Aggregate functions do not accept a VECTOR column, not even COUNT.
11 tasks, 11 with a vector, trigger enabled, model ALL_MINILM_L12_V2 visible
Real runCounted with CASE WHEN title_vec IS NOT NULL it works. 11 tasks, all with a vector, trigger enabled, model visible.
02
Step two

Give the Search Something to Read

DESCRIPTION column · 40 realistic tasks · ORA-01704

Eleven tasks with titles of four or five words are not enough to show what a search can do. Real tasks have a description, and that is where most of the meaning is. So the table gets a DESCRIPTION column, the open tasks from part 1 get a description, and I add 40 tasks that could come from any APEX team. Logins, slow reports, backups, certificates, Excel imports.

My first version put all 40 tasks into one JSON string and read it with JSON_TABLE. Neat, but SQL*Plus answered with ORA-01704. A string literal in SQL can not be longer than 4,000 characters. Plain INSERT statements are boring and they work.

ORA-01704 string literal too long
Real runORA-01704. One literal with 40 tasks in it was far over the 4,000 character limit. The column and the first six descriptions were already in, so I dropped the column and started this step again.
SQL02_add-descriptions-and-sample-tasks.sqlas APEXNOTE
-- (first try used one big JSON string literal: ORA-01704, literals are limited to 4,000 characters; plain INSERTs instead)
set lines 140 pages 60 feedback off
alter table demo_tasks add (description varchar2(2000));

update demo_tasks set description = case id
  when 6  then 'Export the APEXNOTE schema every night with expdp and keep the last seven dump files on the backup volume.'
  when 7  then 'Step by step notes for the team: stop ORDS first, then the database, start in the reverse order and check the APEX login.'
  when 8  then 'Import the all-MiniLM-L12-v2 ONNX model into the database so we can create embeddings with plain SQL.'
  when 9  then 'Users type a question in their own words and get the matching tasks, even when no word matches.'
  when 10 then 'The database container hit its memory limit during the APEX install. Check mem_limit and cpus in the compose file.'
  when 22 then 'The certificate of the reverse proxy expires in 14 days. Renew it and reload the proxy without downtime.'
  else description end;

insert into demo_tasks (title, description, status, priority, owner) values ('Users get logged out after a few minutes',
  'Several users report that APEX sends them back to the login page while they are still working. Check the session idle timeout and the maximum session length.',
  'Open', 'High', 'Demo Developer');
insert into demo_tasks (title, description, status, priority, owner) values ('Customer list loads very slowly',
  'The interactive report with all customers takes more than ten seconds to open. Look at the execution plan and add an index on the country column.',
  'In Progress', 'High', 'Demo Developer');
insert into demo_tasks (title, description, status, priority, owner) values ('Send a reminder e-mail before the due date',
  'Every morning a job should mail the owner of each task that is due tomorrow. Use APEX_MAIL and a scheduler job.',
  'Open', 'Medium', 'Demo Developer');
insert into demo_tasks (title, description, status, priority, owner) values ('Fix ORA-01555 in the monthly sales report',
  'The long running report fails with ORA-01555 snapshot too old when it runs during the nightly batch. Increase undo retention or move the job.',
  'Open', 'High', 'Demo Admin');
insert into demo_tasks (title, description, status, priority, owner) values ('REST call to the payment API fails over HTTPS',
  'APEX_WEB_SERVICE returns ORA-29024 certificate validation failure. The wallet in the container is missing the root certificate of the provider.',
  'In Progress', 'High', 'Demo Admin');
insert into demo_tasks (title, description, status, priority, owner) values ('Translate the app into German',
  'Create a German translation of the Task Board, translate the labels and messages and add a language switch in the navigation bar.',
  'Open', 'Low', 'Demo Developer');
insert into demo_tasks (title, description, status, priority, owner) values ('Dark mode for the Task Board',
  'Offer the Vita Dark theme style and let every user choose light or dark in the user settings.',
  'Open', 'Low', 'Demo Developer');
insert into demo_tasks (title, description, status, priority, owner) values ('Upload attachments to a task',
  'Users want to add PDF and image files to a task. Store them in a BLOB table and show them in a small report on the form.',
  'Open', 'Medium', 'Demo Developer');
insert into demo_tasks (title, description, status, priority, owner) values ('Import tasks from an Excel file',
  'The project office keeps a spreadsheet with open items. Use the Data Load wizard so they can upload the XLSX file themselves.',
  'Open', 'Medium', 'Demo Developer');
insert into demo_tasks (title, description, status, priority, owner) values ('Audit who changed a task',
  'Keep a history of every change with old value, new value, user and timestamp, so we can see who closed or edited a task.',
  'Open', 'Medium', 'Demo Admin');
insert into demo_tasks (title, description, status, priority, owner) values ('Add single sign-on with Microsoft Entra ID',
  'Replace the APEX accounts with an OpenID Connect authentication scheme so employees sign in with their company account.',
  'Open', 'High', 'Demo Admin');
insert into demo_tasks (title, description, status, priority, owner) values ('Rotate the database passwords',
  'Change the passwords of SYS, the schema and the ORDS users every 90 days and update the secrets file of the stack.',
  'Open', 'Medium', 'Demo Admin');
insert into demo_tasks (title, description, status, priority, owner) values ('Disk on the server is almost full',
  'Only 8 percent free space left. Old Data Pump dumps and Docker images take most of it. Clean up and add monitoring.',
  'In Progress', 'High', 'Demo Admin');
insert into demo_tasks (title, description, status, priority, owner) values ('Kanban board view for tasks',
  'Show the tasks as cards in three columns Open, In Progress and Done and let users drag a card to change the status.',
  'Open', 'Medium', 'Demo Developer');
insert into demo_tasks (title, description, status, priority, owner) values ('Calendar of due dates',
  'A calendar page that shows every task on its due date, coloured by priority, with a click to open the task.',
  'Done', 'Low', 'Demo Developer');
insert into demo_tasks (title, description, status, priority, owner) values ('Weekly status report as PDF',
  'Every Friday the team lead wants a PDF with the tasks finished this week and the ones that are late.',
  'Open', 'Medium', 'Demo Developer');
insert into demo_tasks (title, description, status, priority, owner) values ('Mobile layout breaks on small phones',
  'On a phone the task form is wider than the screen and the buttons are cut off. Check the grid layout and the region templates.',
  'Open', 'Medium', 'Demo Developer');
insert into demo_tasks (title, description, status, priority, owner) values ('Restore a single table from last night',
  'Somebody deleted rows in the wrong table. Practise how to bring back one table from the Data Pump export without touching the rest.',
  'Open', 'High', 'Demo Admin');
insert into demo_tasks (title, description, status, priority, owner) values ('Upgrade APEX to the next patch set',
  'Download the latest patch set, test it on a copy of the database and plan a short maintenance window.',
  'Open', 'Medium', 'Demo Admin');
insert into demo_tasks (title, description, status, priority, owner) values ('Speed up the dashboard charts',
  'The home page has four charts that each run a full table scan. Pre-aggregate the numbers once per hour.',
  'Open', 'Medium', 'Demo Developer');
insert into demo_tasks (title, description, status, priority, owner) values ('Password reset link for users',
  'Users who forget their password should get a reset link by e-mail instead of asking the admin.',
  'Open', 'Medium', 'Demo Developer');
insert into demo_tasks (title, description, status, priority, owner) values ('Expose tasks as a REST API',
  'Publish GET and POST handlers with ORDS so the mobile app can read and create tasks, protected with OAuth2 client credentials.',
  'Open', 'High', 'Demo Developer');
insert into demo_tasks (title, description, status, priority, owner) values ('Duplicate tasks are created twice',
  'When a user double-clicks Create, the task is inserted twice. Disable the button after the first click and add a unique check.',
  'Open', 'Medium', 'Demo Developer');
insert into demo_tasks (title, description, status, priority, owner) values ('Log slow pages',
  'Find the pages with the highest elapsed time in the APEX activity log and write them to a weekly list.',
  'Open', 'Low', 'Demo Admin');
insert into demo_tasks (title, description, status, priority, owner) values ('Move the stack to a bigger server',
  'The demo server has only 2 CPUs. Copy the volumes, start the containers on the new machine and switch the DNS entry.',
  'Open', 'Low', 'Demo Admin');
insert into demo_tasks (title, description, status, priority, owner) values ('Firewall only allows the web ports',
  'Close every port except 80 and 443 to the outside. The database listener must only be reachable from the ORDS container.',
  'Done', 'High', 'Demo Admin');
insert into demo_tasks (title, description, status, priority, owner) values ('Onboarding checklist for new developers',
  'A short list with the accounts, tools and first steps a new developer needs on day one.',
  'Open', 'Low', 'Demo Developer');
insert into demo_tasks (title, description, status, priority, owner) values ('Search tasks by meaning',
  'Add AI vector search to the Task Board so users find tasks with their own words, using the ONNX model inside the database.',
  'In Progress', 'High', 'Demo Developer');
insert into demo_tasks (title, description, status, priority, owner) values ('Show overdue tasks in red',
  'In the task report, every open task with a due date in the past should be highlighted in red.',
  'Done', 'Low', 'Demo Developer');
insert into demo_tasks (title, description, status, priority, owner) values ('Export the task list to CSV',
  'Business users want to download the filtered task list and open it in Excel.',
  'Done', 'Low', 'Demo Developer');
insert into demo_tasks (title, description, status, priority, owner) values ('Notifications in Microsoft Teams',
  'Post a message to the team channel through an incoming webhook whenever a high priority task is created.',
  'Open', 'Medium', 'Demo Developer');
insert into demo_tasks (title, description, status, priority, owner) values ('Archive tasks older than two years',
  'Move finished tasks older than two years to an archive table to keep the main table small and fast.',
  'Open', 'Low', 'Demo Admin');
insert into demo_tasks (title, description, status, priority, owner) values ('Database does not start after a reboot',
  'After the host was restarted the database container stayed in starting state. The listener came up but the PDB was not opened.',
  'Done', 'High', 'Demo Admin');
insert into demo_tasks (title, description, status, priority, owner) values ('Charts show wrong numbers for last month',
  'The monthly chart counts tasks by created date in UTC, so tasks created late in the evening land in the wrong month.',
  'Open', 'Medium', 'Demo Developer');
insert into demo_tasks (title, description, status, priority, owner) values ('Give the support team read-only access',
  'Support needs to see all tasks but must not change anything. Create an authorization scheme with a reader role.',
  'Open', 'Medium', 'Demo Admin');
insert into demo_tasks (title, description, status, priority, owner) values ('Write unit tests for the task package',
  'Cover the create, update and close procedures with utPLSQL tests and run them before every deployment.',
  'Open', 'Low', 'Demo Developer');
insert into demo_tasks (title, description, status, priority, owner) values ('Deploy changes with a pipeline',
  'Export the application and the database objects to Git and install them on the test server automatically after every merge.',
  'Open', 'Medium', 'Demo Developer');
insert into demo_tasks (title, description, status, priority, owner) values ('Users cannot upload files larger than 10 MB',
  'Bigger uploads end with an error in the browser. Check the ORDS and reverse proxy limits for the request body size.',
  'Open', 'Medium', 'Demo Admin');
insert into demo_tasks (title, description, status, priority, owner) values ('Clean up unused APEX pages',
  'The app still contains test pages from the first prototype. Remove them and check that no menu entry points to them.',
  'Open', 'Low', 'Demo Developer');
insert into demo_tasks (title, description, status, priority, owner) values ('Keep the search vectors up to date',
  'When a title or description changes the embedding must change too. A trigger does it on every insert and update.',
  'Done', 'High', 'Demo Developer');
commit;

select count(*) as tasks, count(description) as with_description from demo_tasks;
51 tasks, 46 with a description
Real run51 tasks, 46 with a description. The five finished tasks from part 1 have none, which is realistic too. The trigger from part 2 embedded every new title on insert.
03
Step three

One Search Vector for Title and Description

SEARCH_VEC · 51 rows in 1.9 s · trigger for both

I keep TITLE_VEC from part 2 and add a second vector, SEARCH_VEC, from title and description together. The trigger now fills both, and it also fires when only the description changes.

PL/SQL03_search-vector-column.sqlas APEXNOTE
set lines 140 pages 50 timing on
alter table demo_tasks add (search_vec vector(384, float32));

update demo_tasks
   set search_vec = vector_embedding(apexnote_vec.all_minilm_l12_v2
                                     using title || '. ' || description as data);
commit;
set timing off

create or replace trigger demo_tasks_vec_biu
  before insert or update of title, description on demo_tasks
  for each row
begin
  select vector_embedding(apexnote_vec.all_minilm_l12_v2 using :new.title as data),
         vector_embedding(apexnote_vec.all_minilm_l12_v2 using :new.title || '. ' || :new.description as data)
    into :new.title_vec, :new.search_vec
    from dual;
end;
/
show errors

select count(*) as tasks, count(case when search_vec is not null then 1 end) as with_search_vec from demo_tasks;
OutputSQL*Plusreal run
Table altered.
Elapsed: 00:00:00.10

51 rows updated.
Elapsed: 00:00:01.90

Trigger created.
No errors.

     TASKS WITH_SEARCH_VEC
---------- ---------------
        51              51
Column added, 51 rows updated in 1.90 seconds, trigger created without errors
Real run51 rows in 1.9 seconds. The SELECT ... INTO ... FROM dual form in the trigger is the fix from part 2. VECTOR_EMBEDDING only works in SQL.
Why title plus description?

The model turns one text into one vector. A title like "Disk on the server is almost full" is fine, but "Build the first test app" says almost nothing. The description adds the context that a user later describes in their own words. If the text gets very long, the model only reads the first part of it (this one stops after 512 tokens), so put the important words first.

04
Step four

The Search Query With a Match Score

VECTOR_EMBEDDING once · ORDER BY VECTOR_DISTANCE

This is the query the APEX page will run, in its simplest form. The question is embedded once in a WITH clause, then every task is ranked by cosine distance. Cosine distance goes from 0 (same meaning) upwards, and 1 - distance is the cosine similarity. Times 100 gives a match in percent that a user can read.

SQL04_semantic-search-query.sqlas APEXNOTE
set lines 150 pages 50 feedback off
col title format a50
col match_pct format 990
variable q varchar2(200)

exec :q := 'people keep getting kicked out of the app'

with question as (
  select vector_embedding(apexnote_vec.all_minilm_l12_v2 using :q as data) as v from dual
)
select t.id, t.title,
       round((1 - vector_distance(t.search_vec, question.v, cosine)) * 100) as match_pct
  from demo_tasks t, question
 order by vector_distance(t.search_vec, question.v, cosine)
 fetch first 3 rows only;

exec :q := 'the server is running out of storage'
/
exec :q := 'how do we get yesterdays data back'
/
OutputSQL*Plusreal run
-- 'people keep getting kicked out of the app'
        ID TITLE                                              MATCH_PCT
---------- -------------------------------------------------- ---------
        41 Users get logged out after a few minutes                  38
        98 Clean up unused APEX pages                                25
         5 Build the first test app                                  23

-- 'the server is running out of storage'
        72 Disk on the server is almost full                         70
        97 Users cannot upload files larger than 10 MB               44
        10 Review memory and CPU limits of the containers            34

-- 'how do we get yesterdays data back'
        77 Restore a single table from last night                    54
        93 Charts show wrong numbers for last month                  38
        79 Speed up the dashboard charts                             31
Three questions with their top three tasks and match percentages
Real runAll three questions find the right task first. "Out of storage" gets 70 %, because the description of the disk task is very close. "Kicked out" gets only 38 %, the words are further away, and it is still clearly first.
Do not read the percentages like school grades.

With this model 30 to 40 % is already a good match for a short question. What counts is the order and the gap to the next result. The absolute numbers depend on the model, so if you switch to another model, check your thresholds again.

05
Step five

Compare It With LIKE

four questions · obvious keyword vs. vector

To be fair to LIKE, I gave it the one word from each question that a user would most likely type, and let it search in title and description.

SQL05_like-vs-vector.sqlas APEXNOTE
set lines 160 pages 50 feedback off
col question format a42
col keyword format a10
col vector_top_hit format a45
with q (question, keyword) as (
  select 'people keep getting kicked out of the app', 'kicked'    from dual union all
  select 'the server is running out of storage',      'storage'   from dual union all
  select 'how do we get yesterdays data back',        'yesterday' from dual union all
  select 'login with company account',                'company'   from dual
)
select q.question, q.keyword,
       (select count(*) from demo_tasks t
         where lower(t.title || ' ' || t.description) like '%' || q.keyword || '%') as like_hits,
       (select t.title from demo_tasks t
         order by vector_distance(t.search_vec,
                    vector_embedding(apexnote_vec.all_minilm_l12_v2 using q.question as data), cosine)
         fetch first 1 row only) as vector_top_hit
  from q;
OutputSQL*Plusreal run
QUESTION                                   KEYWORD     LIKE_HITS VECTOR_TOP_HIT
------------------------------------------ ---------- ---------- ---------------------------------------------
people keep getting kicked out of the app  kicked              0 Users get logged out after a few minutes
the server is running out of storage       storage             0 Disk on the server is almost full
how do we get yesterdays data back         yesterday           0 Restore a single table from last night
login with company account                 company             1 Add single sign-on with Microsoft Entra ID
LIKE hits 0, 0, 0, 1 while the vector search finds the right task four times
Real runLIKE finds 0, 0, 0 and 1 rows. The vector search finds the right task four times out of four. The one LIKE hit is the same task the vector search found.
06
Step six

A Minimum Match Against Nonsense

best pizza in town · threshold 25 %

There is one thing a vector search never does. It never says "nothing found". There is always a closest vector, even if the question has nothing to do with your data.

SQL06_threshold.sqlas APEXNOTE
set lines 150 pages 50 feedback on
col title format a50
col match_pct format 990
variable q varchar2(200)
exec :q := 'best pizza in town'

-- without a threshold: three "results" for a question that has nothing to do with our tasks
with question as (
  select vector_embedding(apexnote_vec.all_minilm_l12_v2 using :q as data) as v from dual
)
select t.title, round((1 - vector_distance(t.search_vec, question.v, cosine)) * 100) as match_pct
  from demo_tasks t, question
 order by vector_distance(t.search_vec, question.v, cosine)
 fetch first 3 rows only;

-- with a threshold: only rows with at least 25 % match (cosine distance <= 0.75)
with question as (
  select vector_embedding(apexnote_vec.all_minilm_l12_v2 using :q as data) as v from dual
)
select t.title, round((1 - vector_distance(t.search_vec, question.v, cosine)) * 100) as match_pct
  from demo_tasks t, question
 where vector_distance(t.search_vec, question.v, cosine) <= 0.75
 order by vector_distance(t.search_vec, question.v, cosine)
 fetch first 3 rows only;

exec :q := 'the server is running out of storage'
/
OutputSQL*Plusreal run
-- without a threshold, 'best pizza in town'
TITLE                                              MATCH_PCT
-------------------------------------------------- ---------
Customer list loads very slowly                            6
Build semantic search page                                 5
Add single sign-on with Microsoft Entra ID                 4

-- with a threshold (distance <= 0.75)
no rows selected

-- with a threshold, 'the server is running out of storage'
Disk on the server is almost full                         70
Users cannot upload files larger than 10 MB               44
Review memory and CPU limits of the containers            34
Pizza question returns 6, 5 and 4 percent without threshold and no rows with it
Real runWithout a threshold, "best pizza in town" returns three tasks with 4 to 6 %. With a minimum of 25 %, no rows. Real questions are not affected.

I picked 25 % after looking at my real questions. Every good hit was above 30 %, every unrelated row below 25 %. In the APEX page the user can change it.

07
Step seven

Hybrid Search for Error Codes

ORA-29024 · vector score + keyword bonus

Now the weak spot. Search for ORA-29024. One task mentions exactly this error in its description. The model does not know what ORA-29024 is, for it this is a string of letters and digits, and it ranks the installation tasks first. The real task gets 12 %.

The fix is old school. If the exact search text appears in title or description, the row gets 50 bonus points on top of its vector score. Meaning still decides the order for normal questions, exact matches win for codes, IDs and names.

SQL07_hybrid-search.sqlas APEXNOTE
set lines 150 pages 50 feedback off
col title format a48
col vector_pct format 990
col keyword_bonus format 990
col score format 990
variable q varchar2(200)
exec :q := 'ORA-29024'

-- vector only: the task that really mentions ORA-29024 is not in the top 3
with question as (
  select vector_embedding(apexnote_vec.all_minilm_l12_v2 using :q as data) as v from dual
)
select t.id, t.title, round((1 - vector_distance(t.search_vec, question.v, cosine)) * 100) as vector_pct
  from demo_tasks t, question
 order by vector_distance(t.search_vec, question.v, cosine)
 fetch first 3 rows only;

-- hybrid: + 50 points when the exact search text appears in title or description
with question as (
  select vector_embedding(apexnote_vec.all_minilm_l12_v2 using :q as data) as v from dual
), scored as (
  select t.id, t.title,
         round((1 - vector_distance(t.search_vec, question.v, cosine)) * 100) as vector_pct,
         case when instr(lower(t.title || ' ' || t.description), lower(:q)) > 0 then 50 else 0 end as keyword_bonus
    from demo_tasks t, question
)
select id, title, vector_pct, keyword_bonus, vector_pct + keyword_bonus as score
  from scored
 order by score desc
 fetch first 3 rows only;

-- and a normal question still ranks by meaning (no keyword bonus anywhere)
exec :q := 'people keep getting kicked out of the app'
/
OutputSQL*Plusreal run
-- vector only, 'ORA-29024'
        ID TITLE                                            VECTOR_PCT
---------- ------------------------------------------------ ----------
         2 Install ORDS and APEX 26.2                               41
         1 Install Oracle AI Database 26ai Free in Docker           32
        63 Fix ORA-01555 in the monthly sales report                30

-- hybrid, 'ORA-29024'
        ID TITLE                                            VECTOR_PCT KEYWORD_BONUS SCORE
---------- ------------------------------------------------ ---------- ------------- -----
        64 REST call to the payment API fails over HTTPS            12            50    62
         2 Install ORDS and APEX 26.2                               41             0    41
         1 Install Oracle AI Database 26ai Free in Docker           32             0    32

-- hybrid, 'people keep getting kicked out of the app'
        41 Users get logged out after a few minutes                 38             0    38
        98 Clean up unused APEX pages                               25             0    25
         5 Build the first test app                                 23             0    23
Vector only ranks installation tasks first, hybrid ranks the REST HTTPS task first with score 62
Real runVector only, the real task is not in the top 3. Hybrid, it is first with 12 + 50 = 62. For a normal question nothing changes, no row gets a bonus.
Simple on purpose.

This keyword bonus only checks the whole search text with INSTR. That is enough for error codes and names, and it needs no extra index. If you need real word matching, stemming and fuzzy search on top, Oracle has hybrid vector indexes that combine Oracle Text and a vector index in one (CREATE HYBRID VECTOR INDEX, searched with DBMS_HYBRID_VECTOR.SEARCH). That is a topic for its own post.


Part B. The APEX Page

The query is ready. The page around it is small, and nothing on it needs a plug-in.

08
Step eight

Build the Smart Search Page

Blank page · 2 items · 1 button · Classic Report with Media List

In the Task Board app, create a new blank page called Smart Search (page 4 in my app, with a navigation menu entry). Then add the following in Page Designer.

ComponentTypeSettings that matter
Ask the Task BoardStatic Content regionA short help text for the user
P4_SEARCHText FieldSubmit when Enter pressed = On, a placeholder with an example question
P4_MIN_MATCHSelect ListStatic values Any;0, 20 %;20, 25 %;25, 30 %;30, 40 %;40. Default 25. Page Action on Selection = Submit Page
SEARCHButtonAction Submit Page, Hot, icon fa-search
ResultsClassic ReportSource SQL Query (below). Appearance Template = Media List, template options Show Description and Show Badges. Server-side Condition Item is NOT NULL, P4_SEARCH
P3_DESCRIPTIONTextarea on page 3 (the task form)Source column DESCRIPTION, so users can write descriptions
Page Designer with the Smart Search page, items P4_SEARCH and P4_MIN_MATCH, button SEARCH and region Results
Real runPage 4 in Page Designer. One static region with two items and the button, one report region.

The Media List template expects columns with fixed names. LIST_TITLE, LIST_TEXT, LIST_BADGE, ICON_CLASS, ICON_COLOR_CLASS and LINK, plus three optional ones. So the region SQL is the hybrid query from step 7 with these aliases. The status becomes the icon, the priority its colour, and APEX_PAGE.GET_URL opens the task form as a drawer when you click a hit.

SQLResults region, SQL Querypage 4
with question as (
  select vector_embedding(apexnote_vec.all_minilm_l12_v2 using :P4_SEARCH as data) as v
    from dual
), scored as (
  select t.id, t.title, t.description, t.status, t.priority,
         round((1 - vector_distance(t.search_vec, question.v, cosine)) * 100) as vector_pct,
         case when instr(lower(t.title || ' ' || t.description), lower(:P4_SEARCH)) > 0
              then 50 else 0 end as keyword_bonus
    from demo_tasks t, question
)
select title                                         as list_title,
       description                                   as list_text,
       to_char(least(vector_pct + keyword_bonus, 100), 'fm990') || ' %' as list_badge,
       case status when 'Done'        then 'fa fa-check-circle'
                   when 'In Progress' then 'fa fa-spinner'
                   else 'fa fa-circle-o' end          as icon_class,
       case priority when 'High'   then 'u-danger'
                     when 'Medium' then 'u-warning'
                     else 'u-success' end             as icon_color_class,
       apex_page.get_url(p_page => 3, p_items => 'P3_ID', p_values => id) as link,
       null as link_class, null as link_attr, null as list_class
  from scored
 where vector_pct + keyword_bonus >= nvl(:P4_MIN_MATCH, 0)
 order by vector_pct + keyword_bonus desc
 fetch first 10 rows only
Property editor of the Results region showing type Classic Report and the SQL query
Real runThe Results region. Classic Report, local database, SQL query. The red dot in the tree only means the region has a server-side condition.
Property editor of the item P4_SEARCH
Real runP4_SEARCH. A normal text field, nothing special about it.

The first version of the page had a small surprise in it.

The badge shows 3.8E+001 % instead of 38 %
Real run"3.8E+001 %" instead of "38 %". VECTOR_DISTANCE returns a BINARY_DOUBLE, so ROUND returns one too, and converting that to text gives scientific notation. The icons were empty as well.
SQLLIST_BADGEshows 3.8E+001 %
least(vector_pct + keyword_bonus, 100) || ' %' as list_badge
SQLLIST_BADGEshows 38 %
to_char(least(vector_pct + keyword_bonus, 100), 'fm990') || ' %' as list_badge

The empty icons had a simple reason. The Media List template writes ICON_CLASS into a t-Icon span, and Font APEX icons need the base class fa next to the icon name. So fa fa-check-circle, not just fa-check-circle.

The model grant matters here too.

The region runs in the parsing schema of the app, APEXNOTE. That is why the grant from part 2 (GRANT SELECT ON MINING MODEL ... TO apexnote) is needed. Without it, the page shows ORA-40284 "model does not exist".

09
Step nine

Try It in the App

logged-in user · real clicks · recorded

Now as a normal user in the running app. The home page has a new card, and the search page starts empty.

Task Board home page with the cards Tasks and Smart Search
Real runA second card on the home page.
Empty Smart Search page with question field, minimum match 25 percent and search button
Real runThe empty page. The results region only appears when there is a question.
Smart Search for how do we get yesterdays data back with Restore a single table from last night first
Real run"How do we get yesterdays data back" finds "Restore a single table from last night" with 54 %. The next ones are well below.
Smart Search for best pizza in town shows the no data found message
Real runThe pizza test in the app. Nothing reaches 25 %, so the user gets a helpful message instead of random tasks.
With minimum match Any the pizza question returns unrelated tasks with 3 to 6 percent
Real runMinimum match set to Any. Now the junk is back, with 3 to 6 %. This is what every vector search returns without a threshold.
Smart Search for ORA-29024 shows the REST call task first with 62 percent
Real runThe error code. The keyword bonus puts the right task first with 62 %.
Clicking the hit opens the task in the drawer with its description
Real runA click on a hit opens the normal task form as a drawer, now with the description field.
10
Step ten

New Tasks Are Searchable Right Away

trigger on insert · ORA-01400 from part 1

The real test for the trigger. I create a new task in the app and search for it with completely different words.

Create task form with title Invoices arrive twice in the customer mailbox and a description
Real runA new task with a description, typed into the normal APEX form.
ORA-01400 cannot insert NULL into APEXNOTE.DEMO_TASKS.CREATED_ON
Real runORA-01400. This one has nothing to do with vectors. It is a bug from part 1 that nobody noticed, because I never created a task in the app before.

The form from part 1 has a hidden item for CREATED_ON. On insert it sends NULL for that column, and a normal DEFAULT systimestamp is ignored when a value, even NULL, is given. DEFAULT ON NULL handles exactly this case.

SQL17_created-on-default-on-null.sqlas APEXNOTE
-- A plain DEFAULT does not help when NULL is passed explicitly; DEFAULT ON NULL does.
-- connect: app
set lines 140 pages 50
col column_name format a12
col data_default format a40
select column_name, data_default, default_on_null from user_tab_columns where table_name = 'DEMO_TASKS' and column_name = 'CREATED_ON';
alter table demo_tasks modify created_on default on null systimestamp;
select column_name, data_default, default_on_null from user_tab_columns where table_name = 'DEMO_TASKS' and column_name = 'CREATED_ON';
OutputSQL*Plusreal run
COLUMN_NAME  DATA_DEFAULT    DEF
------------ --------------- ---
CREATED_ON   systimestamp    NO

Table altered.

CREATED_ON   systimestamp    YES
DEFAULT_ON_NULL changes from NO to YES
Real runFrom NO to YES. The form works without any change in APEX.
Smart Search for customers get duplicate bills by e-mail finds the new task Invoices arrive twice in the customer mailbox first
Real runSaved, and right after that "customers get duplicate bills by e-mail" finds "Invoices arrive twice in the customer mailbox" with 52 %. Not one word in common. The trigger embedded it on insert.

Part C. A Vector Index for Big Tables

With 51 tasks the database compares the question with every row, and nobody notices. That is called an exact search. To see where an index starts to make sense, I needed a bigger table.

11
Step eleven

20,000 Support Tickets and an Exact Search

5:19 min to embed · 30 to 40 ms per search

A TICKETS table with 20,000 generated support tickets. Eight systems, seven problems, five situations and three reporters, so every sentence is different.

SQL08_create-ticket-archive.sqlas APEXNOTE
set lines 140 pages 50 timing on feedback on
create table tickets (
  id    number generated always as identity primary key,
  text  varchar2(400) not null,
  vec   vector(384, float32)
);

insert into tickets (text)
select 'Ticket ' || level || ': ' ||
       case mod(level, 8) when 0 then 'the customer portal' when 1 then 'the invoice report' when 2 then 'the login page'
                          when 3 then 'the nightly backup' when 4 then 'the REST API'      when 5 then 'the mobile app'
                          when 6 then 'the e-mail service' else 'the order form' end || ' ' ||
       case mod(level, 7) when 0 then 'is very slow'      when 1 then 'shows an error message' when 2 then 'does not load at all'
                          when 3 then 'sends wrong data'  when 4 then 'times out'               when 5 then 'logs users out'
                          else 'works only sometimes' end || ' ' ||
       case mod(level, 5) when 0 then 'since the last release' when 1 then 'for customers in Germany'
                          when 2 then 'on Monday mornings'    when 3 then 'after the server restart'
                          else 'when many users are online' end ||
       case mod(level, 3) when 0 then ', reported by sales' when 1 then ', reported by support' else ', reported by finance' end
  from dual connect by level <= 20000;
commit;

update tickets set vec = vector_embedding(apexnote_vec.all_minilm_l12_v2 using text as data);
commit;
set timing off
select count(*) as tickets, count(distinct text) as distinct_texts from tickets;
select round(sum(bytes) / 1024 / 1024) as table_mb from user_segments where segment_name = 'TICKETS' or segment_name like 'SYS_LOB%';
OutputSQL*Plusreal run
Table created.
20000 rows created.
Elapsed: 00:00:00.12

20000 rows updated.
Elapsed: 00:05:18.80

   TICKETS DISTINCT_TEXTS
---------- --------------
     20000          20000

  TABLE_MB
----------
        41
20,000 rows created and updated with vectors in 5 minutes 18 seconds
Real run5 minutes and 19 seconds for 20,000 embeddings. About 16 ms per row on one core of the Free edition. You do this once, new rows come one by one through a trigger.
SQL09_exact-search-timing.sqlas APEXNOTE
set lines 150 pages 50 feedback off timing on
col text format a100
variable q varchar2(200)
exec :q := 'the phone app keeps signing people out'

select id, text
  from tickets
 order by vector_distance(vec, vector_embedding(apexnote_vec.all_minilm_l12_v2 using :q as data), cosine)
 fetch first 5 rows only;
/
/
set timing off
explain plan for
select id from tickets
 order by vector_distance(vec, vector_embedding(apexnote_vec.all_minilm_l12_v2 using :q as data), cosine)
 fetch first 5 rows only;
select plan_table_output from table(dbms_xplan.display(format => 'BASIC'));
OutputSQL*Plusreal run
      7005 Ticket 7005: the mobile app logs users out since the last release, reported by sales
      4765 Ticket 4765: the mobile app logs users out since the last release, reported by support
     14565 Ticket 14565: the mobile app logs users out since the last release, reported by sales
      ...
Elapsed: 00:00:00.89     <- first call in this session (model is loaded)
Elapsed: 00:00:00.03
Elapsed: 00:00:00.04

| Id  | Operation               | Name    |
|   0 | SELECT STATEMENT        |         |
|   1 |  COUNT STOPKEY          |         |
|   2 |   VIEW                  |         |
|   3 |    SORT ORDER BY STOPKEY|         |
|   4 |     TABLE ACCESS FULL   | TICKETS |
Exact search over 20,000 tickets returns the mobile app logout tickets in 0.03 to 0.04 seconds with a full table scan
Real runNo index, full table scan, and still only 30 to 40 ms. The 0.89 seconds of the first call is the model being loaded into the session, not the search.
Honest result.

For an APEX app with a few thousand or even 20,000 rows you do not need a vector index. An exact search is also always 100 % accurate. Indexes become important with hundreds of thousands or millions of rows, or with many users searching at the same time. I still wanted to know what it takes, so here it is.

12
Step twelve

HNSW Fails, IVF Works

ORA-51962 · neighbor partitions · 6.2 s

Oracle has two kinds of vector index. HNSW (INMEMORY NEIGHBOR GRAPH) is a graph that lives completely in memory and is the fastest. IVF (NEIGHBOR PARTITIONS) groups the vectors into partitions around centre points and lives on disk like a normal index. I tried HNSW first.

SQL10_hnsw-index_FAILED-no-vector-memory.sqlfails
set lines 140 pages 50 timing on
create vector index tickets_vec_hnsw on tickets (vec)
  organization inmemory neighbor graph
  distance cosine
  with target accuracy 95;
OutputSQL*Plusreal run
create vector index tickets_vec_hnsw on tickets (vec)
                                        *
ERROR at line 1:
ORA-51962: The vector memory area is out of space for the current container.
ORA-51962 The vector memory area is out of space for the current container
Real runORA-51962. HNSW needs the vector pool, and in the Free container vector_memory_size is 0. We saw that value in part 2 already.
SQL11_ivf-index.sqlas APEXNOTE
set lines 150 pages 50 feedback off timing on
col text format a100
create vector index tickets_vec_ivf on tickets (vec)
  organization neighbor partitions
  distance cosine
  with target accuracy 95;

variable q varchar2(200)
exec :q := 'the phone app keeps signing people out'
select id, text
  from tickets
 order by vector_distance(vec, vector_embedding(apexnote_vec.all_minilm_l12_v2 using :q as data), cosine)
 fetch approx first 5 rows only;
/
/
set timing off
explain plan for
select id from tickets
 order by vector_distance(vec, vector_embedding(apexnote_vec.all_minilm_l12_v2 using :q as data), cosine)
 fetch approx first 5 rows only;
select plan_table_output from table(dbms_xplan.display(format => 'BASIC'));
OutputSQL*Plusreal run
Index created.
Elapsed: 00:00:06.16

Elapsed: 00:00:00.87     <- first call in this session
Elapsed: 00:00:00.01
Elapsed: 00:00:00.02

|  13 |              TABLE ACCESS FULL    | VECTOR$TICKETS_VEC_IVF$..._IVF_FLAT_CENTROIDS           |
|  14 |         PARTITION LIST JOIN-FILTER|                                                         |
|  15 |          TABLE ACCESS FULL        | VECTOR$TICKETS_VEC_IVF$..._IVF_FLAT_CENTROID_PARTITIONS |
IVF index created in 6.16 seconds, approximate search in 0.01 to 0.02 seconds, plan uses IVF centroid tables
Real runIVF works without any memory setting. 6.2 seconds to build, then 10 to 20 ms per search. Note FETCH APPROX, without APPROX Oracle does an exact search and ignores the index.
13
Step thirteen

Vector Memory and HNSW

ORA-51950 · spfile + restart · 10.5 s · 38 MB

For HNSW the database needs a vector pool. A normal ALTER SYSTEM in the CDB root, I thought.

SQL12_set-vector-memory_FAILED-ora-51950.sqlfails
set lines 140 pages 50
col name format a22
col value format a12
alter system set vector_memory_size = 256M scope = both;
select name, display_value as value from v$parameter where name in ('sga_target', 'vector_memory_size');
select pool, round(sum(bytes) / 1024 / 1024) as mb from v$sgastat where pool = 'vector pool' group by pool;
OutputSQL*Plusreal run
alter system set vector_memory_size = 256M scope = both
*
ERROR at line 1:
ORA-02097: parameter cannot be modified because specified value is invalid
ORA-51950: The Oracle Database Vector Memory size cannot be increased.
SQL12_set-vector-memory.sqlas SYS in CDB$ROOT
set lines 140 pages 50
alter system set vector_memory_size = 256M scope = spfile;
Shell13_restart-database.shon the server
set -e
cd /opt/apexnote-demo
start=$(date +%s)
docker compose restart db
until [ "$(docker inspect -f '{{.State.Health.Status}}' apexnote-db)" = "healthy" ]; do sleep 3; done
echo "database healthy after $(( $(date +%s) - start )) s"
curl -s -o /dev/null -w "APEX answers with HTTP %{http_code}\n" http://127.0.0.1:8190/ords/r/apexnote/task-board/
Outputbashreal run
 Container apexnote-db Restarting
 Container apexnote-db Started
database healthy after 11 s
APEX answers with HTTP 302
ORA-02097 and ORA-51950 The Oracle Database Vector Memory size cannot be increased
Real runORA-51950. When the instance started with vector_memory_size = 0, it can not be raised online. It goes into the spfile and needs a restart.
docker compose restart db, database healthy after 11 seconds, APEX answers with HTTP 302
Real rundocker compose restart db. Healthy after 11 seconds, APEX answers again. Plan this for a maintenance window on a real system.
SQL14_hnsw-index.sqlas APEXNOTE
set lines 150 pages 50 feedback off
col text format a100
drop index tickets_vec_ivf;
set timing on
create vector index tickets_vec_hnsw on tickets (vec)
  organization inmemory neighbor graph
  distance cosine
  with target accuracy 95;

variable q varchar2(200)
exec :q := 'the phone app keeps signing people out'
select id, text
  from tickets
 order by vector_distance(vec, vector_embedding(apexnote_vec.all_minilm_l12_v2 using :q as data), cosine)
 fetch approx first 5 rows only;
/
/
set timing off
explain plan for
select id from tickets
 order by vector_distance(vec, vector_embedding(apexnote_vec.all_minilm_l12_v2 using :q as data), cosine)
 fetch approx first 5 rows only;
select plan_table_output from table(dbms_xplan.display(format => 'BASIC'));
OutputSQL*Plusreal run
Index created.
Elapsed: 00:00:10.46

Elapsed: 00:00:01.16     <- first call after the restart
Elapsed: 00:00:00.01
Elapsed: 00:00:00.01

|   4 |     TABLE ACCESS BY INDEX ROWID| TICKETS          |
|   5 |      VECTOR INDEX HNSW SCAN    | TICKETS_VEC_HNSW |
SQL15_vector-memory-usage.sqlas SYS in FREEPDB1
set lines 150 pages 50
col pool format a12
select pool, round(alloc_bytes / 1024 / 1024) as alloc_mb, round(used_bytes / 1024 / 1024, 1) as used_mb
  from v$vector_memory_pool order by pool;
OutputSQL*Plusreal run
POOL           ALLOC_MB    USED_MB
------------ ---------- ----------
1MB POOL            224         38
64KB POOL            16         .7
HNSW index created in 10.46 seconds, searches in 0.01 seconds, plan shows VECTOR INDEX HNSW SCAN
Real runHNSW in 10.5 seconds, then 10 ms per search. The plan shows VECTOR INDEX HNSW SCAN. Same five tickets as the exact search.
Vector memory pool 1MB POOL 224 MB allocated 38 MB used
Real runThe graph for 20,000 vectors with 384 dimensions uses 38 MB of the 256 MB pool. The pool comes out of the SGA, so it is memory the buffer cache no longer has.
OptionBuildSearch (warm)NeedsWhen I would use it
No index (exact)none30 to 40 msnothingUp to tens of thousands of rows, always 100 % accurate
IVF6.2 s10 to 20 msnothing extraLarge tables, many changes, little memory
HNSW10.5 sabout 10 msvector pool (38 MB here)Very large tables, many parallel searches, enough RAM
Where the time really goes.

On 20,000 rows all three options are fast, and a big part of the 10 ms is embedding the question itself. The first search in a new database session takes about one second more, because the model is loaded into that session. ORDS reuses its database sessions, so in APEX this hits only the first search after a restart or after a quiet period.


Troubleshooting. The Six Errors I Hit

ErrorWhereReal causeFix
ORA-22849 Type VECTOR is not supported for this function or operatorCOUNT(vector_column)Aggregates do not take VECTORCOUNT(CASE WHEN v IS NOT NULL THEN 1 END)
ORA-01704 string literal too longSeed data as one big JSON stringSQL literals are limited to 4,000 charactersPlain INSERTs, or a CLOB bind variable
3.8E+001 % in the APEX badgeReport column built from ROUND(1 - VECTOR_DISTANCE(...))VECTOR_DISTANCE returns BINARY_DOUBLETO_CHAR(value, 'fm990')
ORA-01400 cannot insert NULL into CREATED_ONAPEX form with a hidden item for the columnThe form sends NULL, a plain default is ignoredDEFAULT ON NULL systimestamp
ORA-51962 vector memory area is out of spaceCREATE VECTOR INDEX ... INMEMORY NEIGHBOR GRAPHvector_memory_size = 0Give the database a vector pool, or use IVF
ORA-51950 (with ORA-02097) vector memory size cannot be increasedALTER SYSTEM ... SCOPE = BOTHThe instance started with 0SCOPE = SPFILE and restart

Speed and Memory

SQL19_page-query-timing.sqlas APEXNOTE
set lines 150 pages 50 feedback off timing on
col list_title format a50
col list_badge format a6
variable P4_SEARCH varchar2(200)
variable P4_MIN_MATCH number
exec :P4_SEARCH := 'people keep getting kicked out of the app'; :P4_MIN_MATCH := 25
with question as (
  select vector_embedding(apexnote_vec.all_minilm_l12_v2 using :P4_SEARCH as data) as v
    from dual
), scored as (
  select t.id, t.title, t.description,
         round((1 - vector_distance(t.search_vec, question.v, cosine)) * 100) as vector_pct,
         case when instr(lower(t.title || ' ' || t.description), lower(:P4_SEARCH)) > 0
              then 50 else 0 end as keyword_bonus
    from demo_tasks t, question
)
select title as list_title,
       to_char(least(vector_pct + keyword_bonus, 100), 'fm990') || ' %' as list_badge
  from scored
 where vector_pct + keyword_bonus >= nvl(:P4_MIN_MATCH, 0)
 order by vector_pct + keyword_bonus desc
 fetch first 10 rows only;
/
/
OutputSQL*Plusreal run
LIST_TITLE                                         LIST_B
-------------------------------------------------- ------
Users get logged out after a few minutes           38 %
Clean up unused APEX pages                         25 %
Elapsed: 00:00:01.15     <- first call in this session
Elapsed: 00:00:00.01
Elapsed: 00:00:00.01
The exact region query of the APEX page runs in 0.01 seconds after the first call
Real runThe region query of the Smart Search page, as it runs in APEX. 10 ms once the model is loaded in the session.
docker stats with the database at 2.28 GiB and ORDS at 796 MiB
Real runAfter the restart with the vector pool the database container uses 2.3 GiB of its 4 GiB, ORDS 0.8 GiB.
WhatMeasured
Embed 51 tasks (title and description)1.9 s
Smart Search page query, 51 tasksabout 10 ms, 1.15 s for the first call in a session
Embed 20,000 tickets5 min 19 s (about 16 ms per row)
Exact search, 20,000 rows30 to 40 ms
IVF index build / search6.2 s / 10 to 20 ms
HNSW index build / search10.5 s / about 10 ms
HNSW graph in the vector pool38 MB of 256 MB
Database restart for the vector poolhealthy after 11 s
Database container RAM after everything2.3 GiB of 4 GiB
Need a hand?
A search in your APEX app that understands your users

Semantic search, duplicate detection, similar records or chat with your own data. We build AI features into Oracle APEX applications that run inside your database, without sending your data anywhere. Get in touch.


What Comes Next

From an empty Linux server to an APEX app that understands questions, in three posts. A few ideas where to go from here.

Part 4 is online: Private AI Search in Oracle APEX: Data In-House, Tenants Apart. What really leaves the server, and how Virtual Private Database keeps franchises and tenants apart.

  • Find duplicates while typing. The same query, run on the title field of the create form, shows "similar tasks already exist" before somebody creates the task a second time.
  • Other languages. For German or mixed texts, swap the model for multilingual-e5-small, as described in part 2. Re-embed once, check the threshold again.
  • Real hybrid indexes. Oracle Text and vectors in one index, with word matching and fuzzy search on top.
  • Chat with your data. The top hits of this search are exactly what you give a language model as context (RAG), so it answers from your own tasks.

Final Thoughts

The part that took the longest was not the vectors. It was the details around them. A threshold, so the page can say "nothing found". A keyword bonus, so error codes still work. A TO_CHAR, so the badge does not show scientific notation. Those are the things that decide whether users trust a search or ignore it.

The search itself is one SQL query in a Classic Report. No plug-in, no service next to the database, no API key, and no data leaving the server. For most APEX apps the table is small enough that you do not even need an index. I find that the most surprising result of this whole series.

If you build this into your own app and something does not work the way it did here, write to me. I read every message.

SH
Sajjad Hanifa
Software Developer · S&H Software Solutions · Oracle APEX, PL/SQL, AI Assistants
Oracle APEX Oracle 26ai AI Vector Search Semantic Search Hybrid Search HNSW IVF Troubleshooting

 {fullWidth}

Please Select Embedded Mode To Show The Comment System.*

Previous Post Next Post

نموذج الاتصال