Skip to content

BUG: FULL_TEXT index (re)build over existing data is broken - CREATE INDEX on a populated type indexes nothing matchable, and REBUILD INDEX crashes and drops the index #4732

Closed

Description

@TheRealMcoy

Description

Two related failures on the FULL_TEXT bulk-build path, both reproduced on a single-property index:

  1. CREATE INDEX ... FULL_TEXT over a type that already has rows reports the rows as indexed (totalIndexed:N) but they never match. Only documents inserted after the index is created are returned by SEARCH_INDEX. So the common "load data, then add a full-text index" flow yields a silently empty index for all pre-existing rows.

  2. REBUILD INDEX <fulltext-index> crashes and leaves the index dropped. The obvious recovery for (1) - rebuild the index from the documents - fails with A FULL_TEXT index requires FullTextIndexMetadata but got com.arcadedb.schema.IndexMetadata, and afterward the index no longer exists (Index with name '...' was not found). The WITH statsOnly = true variant (BM25 corpus-counter repair) works correctly; only the full reindex crashes.

Together these mean a FULL_TEXT index cannot be correctly built or repaired over data that already exists: the create path indexes nothing matchable, and the reindex path destroys the index.

Environment

  • ArcadeDB Server 26.7.1-SNAPSHOT (build 661e52fce3b84f452f02cc131b9c5608674deb67/1782276736394/main)
  • Default database options
  • Reproduced with the default similarity (BM25). The build path is shared with CLASSIC; see the related multi-property report for a CLASSIC repro of the build path crashing.

Root cause

Suspected, two areas:

  1. Build-over-existing (CREATE): the type-scan build that populates a new index from existing records appears not to route those records through the same analyze-and-store path used by live put() (or stores them in a form SEARCH_INDEX does not look up). totalIndexed is reported from the scan count, so it reads as success while no matchable postings were written. The live put() path (engine/.../index/fulltext/LSMTreeFullTextIndex.java#put / putWithStats) is known-good because create-then-insert works; the divergence is in the initial build/scan.

  2. REBUILD: the rebuild path fetches the index's metadata as a base IndexMetadata and then requires a FullTextIndexMetadata, throwing on the type mismatch (A FULL_TEXT index requires FullTextIndexMetadata but got com.arcadedb.schema.IndexMetadata). The full-text metadata round-trip was reworked in PR feat: [#4687] native BM25 full-text scoring (field boosts, caret, EXPLAIN/PROFILE) #4695; the rebuild entry point likely reconstructs a generic IndexMetadata instead of the full-text subtype, and the failure occurs after the old index has already been removed, so the index is left dropped.

Steps to reproduce

# --- (1) build over existing data does not match ---
curl -sS -u root:playwithdata http://localhost:2480/api/v1/command/test \
  -H 'Content-Type: application/json' \
  -d '{"language":"sql","command":"CREATE DOCUMENT TYPE doc"}'
curl -sS -u root:playwithdata http://localhost:2480/api/v1/command/test \
  -H 'Content-Type: application/json' \
  -d '{"language":"sql","command":"CREATE PROPERTY doc.title STRING"}'
curl -sS -u root:playwithdata http://localhost:2480/api/v1/command/test \
  -H 'Content-Type: application/json' \
  -d '{"language":"sql","command":"INSERT INTO doc SET title = '"'"'java database tutorial'"'"'"}'
curl -sS -u root:playwithdata http://localhost:2480/api/v1/command/test \
  -H 'Content-Type: application/json' \
  -d '{"language":"sql","command":"CREATE INDEX ON doc (title) FULL_TEXT"}'
#   -> created, "totalIndexed":1

curl -sS -u root:playwithdata http://localhost:2480/api/v1/query/test \
  -H 'Content-Type: application/json' \
  -d '{"language":"sql","command":"SELECT title FROM doc WHERE SEARCH_INDEX('"'"'doc[title]'"'"', '"'"'java'"'"') = true"}'
#   -> []   (the pre-existing row is NOT matched)

# a row inserted AFTER index creation matches fine:
curl -sS -u root:playwithdata http://localhost:2480/api/v1/command/test \
  -H 'Content-Type: application/json' \
  -d '{"language":"sql","command":"INSERT INTO doc SET title = '"'"'another java doc'"'"'"}'
curl -sS -u root:playwithdata http://localhost:2480/api/v1/query/test \
  -H 'Content-Type: application/json' \
  -d '{"language":"sql","command":"SELECT title FROM doc WHERE SEARCH_INDEX('"'"'doc[title]'"'"', '"'"'java'"'"') = true"}'
#   -> only "another java doc"; the pre-existing "java database tutorial" still missing

# --- (2) REBUILD crashes and drops the index ---
curl -sS -u root:playwithdata http://localhost:2480/api/v1/command/test \
  -H 'Content-Type: application/json' \
  -d '{"language":"sql","command":"REBUILD INDEX `doc[title]`"}'
#   -> IndexException: Error on rebuilding index 'doc[title]'
#        (error=A FULL_TEXT index requires FullTextIndexMetadata but got com.arcadedb.schema.IndexMetadata)
curl -sS -u root:playwithdata http://localhost:2480/api/v1/query/test \
  -H 'Content-Type: application/json' \
  -d '{"language":"sql","command":"SELECT title FROM doc WHERE SEARCH_INDEX('"'"'doc[title]'"'"', '"'"'java'"'"') = true"}'
#   -> SchemaException: Index with name 'doc[title]' was not found   (index is gone)

# contrast: statsOnly rebuild works on a valid (create-then-insert) index
#   REBUILD INDEX `doc[title]` WITH statsOnly = true  -> {"operation":"rebuild index stats","statsRecomputed":N}

Observed

  • CREATE INDEX ON doc (title) FULL_TEXT over a populated type reports "totalIndexed":1 but SEARCH_INDEX returns no pre-existing rows; only post-create inserts match.
  • REBUILD INDEX <fulltext> throws A FULL_TEXT index requires FullTextIndexMetadata but got com.arcadedb.schema.IndexMetadata and the index is dropped (subsequent SEARCH_INDEX -> Index ... was not found).
  • REBUILD INDEX <fulltext> WITH statsOnly = true succeeds.

Expected

  • Creating a FULL_TEXT index over existing data indexes those rows so they are immediately matchable by SEARCH_INDEX (consistent with the reported totalIndexed count).
  • REBUILD INDEX <fulltext> re-analyzes the documents and rebuilds postings without crashing, and never leaves the index dropped on failure (rebuild should be atomic: keep the old index until the new one is built).

Suggested fix

  1. Build path: route the initial type-scan build through the same analyze-and-store logic as live put()/putWithStats so the postings written during build are identical to those written incrementally (and therefore found by SEARCH_INDEX).
  2. REBUILD path: when reconstructing the index during rebuild, preserve the FullTextIndexMetadata subtype (build it from the persisted full-text configuration) instead of a generic IndexMetadata. Make rebuild atomic so a failure does not delete the existing index.

Activity

  1. added this to the 26.7.1 milestone on Jun 24, 2026
  2. self-assigned this
    on Jun 24, 2026
  3. added theissue type on Jun 24, 2026
  4. added a commit that references this issue on Jun 24, 2026
  5. lvca commented on Jun 24, 2026

    @lvca
    Member

    Fixed

  6. added a commit that references this issue on Aug 7, 2026
  7. added a commit that references this issue on Aug 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions