Repository navigation
fix(oracle): knowledge-page search with an Oracle Text index - #4804
Merged
nicoloboschi merged 2 commits intoOct 5, 2026
Merged
nicoloboschi merged 2 commits into
nicoloboschi merged 2 commits into
Conversation
rodrigoedu94-png
added a commit
to rodrigoedu94-png/hindsight
that referenced
this pull request
Sep 28, 2026
OR scores a row by its best single term, so a common word ranks as high as the rare one the question is about. ACCUM matches the same rows and ranks the ones containing more query terms higher. Measured on Oracle AI Database 26ai (Always Free ADB) with a BEIR SciFact sample (100 queries, 1,000 docs x 2 banks, gemini-embedding-001 @1536, RRF k=60): | Variant | nDCG@10 | MRR@10 | Recall@10 | |--------------------------|---------|--------|-----------| | keyword, OR | 0.348 | 0.309 | 0.487 | | keyword, ACCUM | 0.666 | 0.656 | 0.718 | | hybrid RRF, OR | 0.693 | 0.640 | 0.880 | | hybrid RRF, ACCUM | 0.806 | 0.784 | 0.920 | Same conclusion as the knowledge-page arm in vectorize-io#4804. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This was referenced Sep 28, 2026
search_knowledge_pages 500'd on Oracle on every path: - the BM25 arm sent PostgreSQL ts_rank_cd/@@ (ORA-00904 "TS_RANK_CD"); - the snippet used LEFT(), which Oracle does not have (ORA-00904 "LEFT"), so even the vector-only path failed. Changes: - rewriter: LEFT(expr, n) -> DBMS_LOB.SUBSTR(expr, n, 1) (VARCHAR2 and CLOB); - knowledge_bm25_arm: Oracle branch (backend_type="oracle") using CONTAINS/SCORE over the new CTXSYS.CONTEXT index, with the dialect's OR-joined terms switched to ACCUM so pages matching more terms rank higher; - migration c8e2f4a6b1d3: Oracle Text index idx_mental_models_text_search on mental_models(content), SYNC (ON COMMIT); PostgreSQL no-op; - tests for the rewrite and the Oracle arm. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…nowledge_pages Review fix: the backend type was looked up three times in the same block.
nicoloboschi
force-pushed
the
fix/oracle-knowledge-text-search
branch
from
October 5, 2026 16:25
7b28fec to
e8da282
Compare
Merged
This was referenced Oct 14, 2026
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
search_knowledge_pagesreturns 500 on the Oracle backend on every path:knowledge_bm25_armonly knows PostgreSQL text-search backends, so Oracle receivests_rank_cd(...)/@@:LEFT(mm.content, 280); Oracle has noLEFT()(ORA-00904: "LEFT"), so even the vector-only path fails.mental_modelson Oracle (the baseline only indexesmemory_units(text)).Fix
engine/db/oracle.py):LEFT(expr, n)→DBMS_LOB.SUBSTR(expr, n, 1)(VARCHAR2 and CLOB, returns VARCHAR2).LEFT JOINis untouched.knowledge_bm25_arm(..., backend_type="oracle")):CONTAINS(mm.content, …, 1) > 0/SCORE(1) DESC, mirroring the memory-recall arm. The dialect joins terms withOR; this arm swaps it forACCUMso pages matching more query terms rank higher (withOR, Oracle Text scores a document by its best single term, and common words in natural-language questions pulled the wrong page up in the RRF fusion).memory_enginepasses the connection'sbackend_type. PostgreSQL behaviour is unchanged.c8e2f4a6b1d3: Oracle TextCTXSYS.CONTEXTindexidx_mental_models_text_searchonmental_models(content),SYNC (ON COMMIT), idempotent (ORA-00955 ignored); PostgreSQL no-op (the index already exists there).Tests
test_oracle_uses_oracle_text_contains_and_scoreandTestOracleQueryRewriter::test_left_becomes_dbms_lob_substr: without the fix2 failed, with it33 passed(wholetest_knowledge_bm25_dispatch.py+TestOracleQueryRewriter).ruff check,ruff format --checkandty checkclean on the changed files.Measurements (real bank, 8 knowledge pages, 32 fixed queries)
24 lexical queries (a term that appears in exactly one page) + 8 paraphrased semantic questions, same set for every run:
ORACCUM"vector-only" is the endpoint with
LEFT()fixed but the BM25 arm skipped; before this PR it returned 500.Related Oracle fixes: #4627, #4628, #4633–#4637, #4647.
🤖 Generated with Claude Code