> For the complete documentation index, see [llms.txt](https://docs.telys.ai/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.telys.ai/working-with-data/update-records.md).

# Update records

`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.

{% hint style="info" %}
`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](/start-here/verify-install.md).
{% endhint %}

## 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](/working-with-data/add-and-upsert.md).

## Update existing rows

```python
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](/working-with-data/delete-and-compact.md) and [Versioning, soft-delete & compaction](/understand-telys/versioning-soft-delete-compaction.md).

```python
col.compact()
col.save()
```

## Expected result

An update changes content without changing which IDs are live:

```python
print(len(col))                 # unchanged by the update
print("note-42" in col)         # -> True

hits = col.search_text("August planning", top_k=1, with_metadata=True)
print(hits["ids"][0], hits["metadata"][0])
```

```
1240
True
note-42 {'scope': 'user:42', 'topic': 'planning', 'rev': 3}
```

{% hint style="warning" %}
`update_texts` is local-only; it is **not** available over a [RemoteTelys](/reference/remote-api.md) connection. `RemoteCollection` exposes `add_texts` and `upsert_texts`, so use `upsert_texts` to replace rows remotely.
{% endhint %}

## Next steps

<table data-view="cards"><thead><tr><th></th><th></th><th data-hidden data-card-target data-type="content-ref"></th></tr></thead><tbody><tr><td><strong>Delete &#x26; compact</strong></td><td>Remove rows and reclaim the space updates leave behind.</td><td><a href="/pages/RllSb4oFIVsEKxs8s4a3">/pages/RllSb4oFIVsEKxs8s4a3</a></td></tr><tr><td><strong>Add &#x26; upsert records</strong></td><td>Write new rows, or new-and-existing in one call.</td><td><a href="/pages/673hmQEbZWacJ4KiSdnW">/pages/673hmQEbZWacJ4KiSdnW</a></td></tr><tr><td><strong>Versioning &#x26; compaction</strong></td><td>How soft-delete and compaction work under the hood.</td><td><a href="/pages/6OLpYuGrmMrjReVdWDhE">/pages/6OLpYuGrmMrjReVdWDhE</a></td></tr></tbody></table>


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.telys.ai/working-with-data/update-records.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
