Skip to content

feat: add FTS support for Collection::CreateIndex/DropIndex#445

Merged
egolearner merged 4 commits into
alibaba:mainfrom
egolearner:feat/fts-create-drop-index
Jun 3, 2026
Merged

feat: add FTS support for Collection::CreateIndex/DropIndex#445
egolearner merged 4 commits into
alibaba:mainfrom
egolearner:feat/fts-create-drop-index

Conversation

@egolearner
Copy link
Copy Markdown
Collaborator

Enable dynamic creation and removal of FTS indexes on existing STRING columns through the standard CreateIndex/DropIndex API, matching the lifecycle model already used by vector and scalar (invert) indexes.

Key changes:

  • New FtsIndexer class (fts_indexer.h/cc) encapsulating per-segment FTS RocksDB management: multi-field lifecycle, snapshot, insert, seal
  • New BlockType::FTS_INDEX with block_id-based directory naming (fts.<block_id>.rocksdb) for crash-safe snapshot-and-swap
  • Segment::create_fts_index builds FTS index on a snapshot copy by scanning forward store, then outputs new SegmentMeta + FtsIndexer for atomic reload (same pattern as create_scalar_index)
  • Segment::drop_fts_index snapshots, removes field CFs, outputs updated meta (or nullptr when last FTS field is removed)
  • Collection layer wires FTS into the existing task dispatch, version update, and reload loops alongside vector/invert paths
  • CreateIndex/DropIndex reject unsupported index types explicitly instead of falling through to the wrong branch

@egolearner egolearner requested a review from feihongxu0824 June 2, 2026 06:36
@egolearner egolearner force-pushed the feat/fts-create-drop-index branch 2 times, most recently from 0386688 to f6af38f Compare June 2, 2026 08:27
Comment thread src/db/index/segment/segment.h Outdated
Comment thread src/db/index/segment/segment.cc Outdated
Comment thread src/db/index/segment/segment.h
Comment thread src/db/index/common/schema.cc
Comment thread src/db/index/segment/segment.cc
@egolearner egolearner force-pushed the feat/fts-create-drop-index branch 3 times, most recently from 5541129 to ec5a299 Compare June 2, 2026 13:38
Comment thread src/db/index/common/schema.cc Outdated
@egolearner egolearner force-pushed the feat/fts-create-drop-index branch from 4b4aac2 to 74582b6 Compare June 3, 2026 02:42
@feihongxu0824 feihongxu0824 self-requested a review June 3, 2026 03:39
feihongxu0824
feihongxu0824 previously approved these changes Jun 3, 2026
Copy link
Copy Markdown
Collaborator

@feihongxu0824 feihongxu0824 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Enable dynamic creation and removal of FTS indexes on existing STRING
columns through the standard CreateIndex/DropIndex API, matching the
lifecycle model already used by vector and scalar (invert) indexes.

Key changes:
- New FtsIndexer class (fts_indexer.h/cc) encapsulating per-segment FTS
  RocksDB management: multi-field lifecycle, snapshot, insert, seal
- New BlockType::FTS_INDEX with block_id-based directory naming
  (fts.<block_id>.rocksdb) for crash-safe snapshot-and-swap
- Segment::create_fts_index builds FTS index on a snapshot copy by
  scanning forward store, then outputs new SegmentMeta + FtsIndexer
  for atomic reload (same pattern as create_scalar_index)
- Segment::drop_fts_index snapshots, removes field CFs, outputs updated
  meta (or nullptr when last FTS field is removed)
- Collection layer wires FTS into the existing task dispatch, version
  update, and reload loops alongside vector/invert paths
- CreateIndex/DropIndex reject unsupported index types explicitly
  instead of falling through to the wrong branch
    fix: address review comments for FTS CreateIndex/DropIndex

    - Reject CreateIndex when column already has a different index type
      (e.g. FTS on an INVERT-indexed column) at both Collection and
      Segment layers
    - Allow same-type different-params CreateIndex to rebuild the index
      (remove old + create new + replay data), aligned with INVERT behavior
    - Return OK when CreateIndex is called with identical params
    - Rename operator[] to get() in both FtsIndexer and InvertedIndexer
    - Add test cases: create→drop→create→drop cycle, and params-change
      rebuild with case-sensitivity verification
@egolearner egolearner merged commit 443500d into alibaba:main Jun 3, 2026
5 of 13 checks passed
@egolearner egolearner deleted the feat/fts-create-drop-index branch June 3, 2026 09:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants