Skip to main content

Text index management

Text indexes are declared and built through the Python SDK. The index lives under the table path and is maintained on write.

Declare an index​

catalog.create_table(
name="documents",
path="s3://my-bucket/warehouse/documents",
schema=documents_schema,
primary_keys=["id"],
text_index=[{
"column": "body",
"tokenizer": "jieba",
"with_positions": True,
}],
)
KeyDefaultMeaning
columnrequiredUtf8 / Utf8View column
tokenizerjiebajieba, default, en_stem, whitespace, raw
with_positionsTrueStore positions for phrase queries
storedFalseStore the original text in the index
rebuild_modeautoauto or none
max_delta_ratio1.0Delta-to-base ratio that triggers compaction

The table needs an Int64 or UInt64 primary key. The configuration is stored on the table, and write_arrow updates the index after the data commit.

Build or rebuild​

from lakesoul.text_index import build_table_text_index

build_table_text_index(
table_name="documents",
namespace="default",
text_column="body",
tokenizer="jieba",
)

Per partition:

from lakesoul.text_index import build_partition_text_index

build_partition_text_index(
table_name="documents",
namespace="default",
partition_desc="range=2026-01-01",
text_column="body",
tokenizer="jieba",
)

rebuild=True rebuilds every shard from its active data files. store_config takes object store credentials; when omitted, the SDK reads LAKESOUL_OBJECT_STORE_*.

Shards and maintenance​

  • The index is built per (partition, hash bucket) shard.
  • New rows are appended as delta segments; searches merge base and delta results.
  • When the delta-to-base ratio exceeds max_delta_ratio, the shard is compacted. Set rebuild_mode="none" to disable automatic compaction and run it yourself.

Next​