Skip to content
For the complete documentation index, see llms.txt. This page is also available as Markdown.

Update records

Replace the contents of existing records with update_texts, and understand how it differs from add_texts and upsert_texts.

update_texts(texts, ids, metadata) replaces the content of rows that already exist. It re-embeds each text and swaps the stored vector and metadata for the matching external ID, leaving the ID and the live row count unchanged. Use it when every ID is present and you want to correct or refresh its content.

update_texts embeds text, so the collection needs an attached embedder, and the lexical embedders need the native kernel. A RuntimeError means no embedder is attached; an ImportError means the kernel is missing. Run telys runtime verify — see Verify your install.

Choose the right write method

Telys has three text-ingest methods. They differ only in how they treat new versus existing IDs.

Method
New IDs
Existing IDs
Needs embedder

add_texts

inserted

KeyError

yes

upsert_texts

inserted

replaced

yes

update_texts

not created

replaced

yes

update_texts is the strict counterpart of add_texts: add_texts writes only new IDs, update_texts writes only existing ones. For a batch that mixes new and existing IDs, use upsert_texts instead — see Add & upsert records.

Update existing rows

from telys import Telys
from telys.embedding import AlgentaMultigramEmbedder

telys = Telys("./telys-data")
# "notes" was created with filter_columns=("scope", "topic", "rev"), so those
# keys round-trip through with_metadata=True (see the Expected result below).
col = telys.open_collection("notes", embedder=AlgentaMultigramEmbedder())

col.update_texts(
    texts=["Q3 planning moved to the first week of August."],
    ids=["note-42"],
    metadata=[{"scope": "user:42", "topic": "planning", "rev": 3}],
)

The return value is the list of updated external IDs. The metadata you pass replaces the previous metadata for that row — it is not merged, so include every field you want to keep.

Versioned-update semantics

Replacing a row does not overwrite the old vector in place. Telys writes a new version and soft-deletes the previous one, so:

  • The live row count stays the same — len(col) and ids() are unaffected by an update.

  • Searches immediately return the new content; the superseded version is no longer visible.

  • The space held by superseded versions is reclaimed by compact().

After a batch of updates or deletes, run compact() to reclaim space, then save() to commit. See Delete & compact and Versioning, soft-delete & compaction.

Expected result

An update changes content without changing which IDs are live:

Next steps

Last updated

Was this helpful?