Infinity Schema Synchronization#
Infinity stores chunks in per-dataset tables named {baseName}_{datasetID} . The column schema for these tables is driven by conf/infinity_mapping.json ā the single source of truth for which fields exist, their types, defaults, analyzers, and index configuration. Any field emitted by a parser or chunker that is absent from this file causes Infinity error 3013 ("Column X not found in table") at insert time.
Schema synchronization operates at two layers:
- Static mapping ā
infinity_mapping.jsondeclares all known fields; it is read at table-creation time . - Runtime reconciliation ā parser-specific or newly-added columns are added to an existing table at insert time via
AddColumns, without requiring a full table drop/recreate.
The Mapping File: conf/infinity_mapping.json#
conf/infinity_mapping.json defines ~97 fields covering every column that parsers and chunkers may write. Key structural groups:
| Group | Examples |
|---|---|
| Chunk identity | id, doc_id, kb_id, mom_id, mom |
| Text/search | content (varchar, rag-coarse/rag-fine), docnm, important_keywords, questions, authors |
| Position | page_num_int, top_int, position_int (all varchar, hex-encoded) |
| Knowledge graph | knowledge_graph_kwd, entities_kwd, from_entity_kwd, to_entity_kwd |
| Chunker-specific | raptor_kwd, raptor_layer_int, mom, chunk_data (table parser), deleted_doc_id |
| JSON list | source_chunk_ids, source_doc_ids, entity_names_kwd (type json) |
The file is loaded by createChunkStoreWithDB, which translates each entry into an infinity.ColumnDefinition, appends the embedding vector column (q_{N}_vec), then creates HNSW, full-text, and secondary indexes as declared.
Table Creation and Runtime Column Reconciliation#
New tables#
CreateChunkStore ā createChunkStoreWithDB reads the mapping file and creates the table with all declared columns plus the embedding vector column. For the table parser, a chunk_data JSON column is added at creation time .
Existing tables#
When InsertChunks opens an existing table instead of creating one, two reconciliation paths apply:
- Embedding model change:
createChunkStoreWithDBdetects a missingq_{N}_veccolumn and adds it viaAddColumns. - Table-parser
chunk_data: both the creation path and the insert path callensureChunkDataColumn, which issuesAddColumnsif the column is absent ā matching Python'sensure_columnspattern .
Python-side ensure_columns#
PR #17685 introduced InfinityConnection.ensure_columns in rag/utils/infinity_conn.py ā a best-effort helper that calls Infinity add_columns for any column missing on an existing chunk table (idempotent). It is invoked before insert when writing doc-deletion marker rows with deleted_doc_id .
Auto-create on insert#
If InsertChunks finds the table does not exist at all, it infers the embedding dimension from the chunk fields and calls createChunkStoreWithDB to create the table on the fly .
Field Name Translation (transformChunkFields)#
Parsers and chunkers produce chunks using Elasticsearch-compatible field names. transformChunkFields converts these to the collapsed Infinity column names before insert:
| Chunk field(s) | Infinity column | Notes |
|---|---|---|
docnm_kwd, title_tks, title_sm_tks | docnm | title_kwd also written directly |
content_with_weight / content_ltks / content_sm_ltks | content | priority: content_with_weight wins |
important_kwd | important_keywords + important_kwd_empty_count | empty entries counted separately |
question_kwd | questions | joined by \n |
tag_kwd | tag_kwd | joined by ### |
position_int, page_num_int, top_int | same name | hex-encoded from integer arrays |
chunk_data, extra | same name | JSON-encoded |
tenant_id | (dropped) | routing is by table name |
authors_tks / authors_sm_tks | authors |
Fields not matching a special case fall through to generic rules: JSON columns are JSON-encoded, _feas fields are JSON-serialized, _kwd-suffix list fields are ###-joined, and everything else is passed through verbatim .
Implication: a field emitted by a parser that is both unrecognized by transformChunkFields and absent from infinity_mapping.json will be forwarded verbatim to Infinity and fail with error 3013.
PPTX slide_number and the Sync Gap#
PR #18254 (merged 2026-09-01) replaced the Go PPTX parser's PlainText() approach (which collapsed all slides into one chunk) with a structured IR path. buildPPTXJSONSections in pptx_ir.go now emits one item per slide, each carrying:
{"text": "...", "doc_type_kwd": "text", "slide_number": <1-based int>}
slide_number is not declared in conf/infinity_mapping.json and has no translation in transformChunkFields. When a PPTX chunk reaches InsertChunks, slide_number passes through verbatim and Infinity rejects the insert with "Column slide_number not found".
To resolve: add slide_number to conf/infinity_mapping.json (e.g., {"type": "integer", "default": 0}) so new tables include it, and pair that with a runtime ensure_columns / AddColumns call for pre-existing tables. If the field is not needed downstream (e.g., readers never query by slide number), drop it in transformChunkFields instead.
Historical Schema Gaps and the Fix Pattern#
Schema mismatches recur each time a parser or chunker introduces a new field without a corresponding mapping entry. Known examples:
| Field | Chunker/feature | Fix PR |
|---|---|---|
mom | Parent-child chunker | #13821 |
raptor_kwd | RAPTOR chunker | #11146 |
deleted_doc_id | Doc-deletion tracking | #17685 |
Each was surfaced by the error INSERT: Column X not found in table and fixed by:
- Adding the field to
conf/infinity_mapping.jsonso new tables include it . - Runtime column addition for pre-existing tables ā either via Go
AddColumnsor Pythonensure_columns.
Checklist when adding a new parser/chunker field#
- Add the field to
conf/infinity_mapping.jsonwith the correct type, default, and (if needed) analyzer or index type. - If the field needs name translation, add a case to
transformChunkFields. - For pre-existing tables that must be upgraded in-place, call
ensure_columns(Python) orensureChunkDataColumn-pattern (Go) before the first insert. - If the field is parser-specific and not needed in Infinity, drop it in
transformChunkFields(liketenant_idat ).