---
title: "Remove erased records from every index · Agent Wranglers"
url: https://agentwranglers.se/playbook/search/index-contents-and-sync/erase-from-indexes
id: SRH-8
level: Required
risk: data
updated: 2026-10-27
build: a2a6bdfed830
tokens: 1013
licence: "CC BY 4.0"
licence_url: https://creativecommons.org/licenses/by/4.0/
---

# Remove erased records from every index

For AI agents: the [site map](https://agentwranglers.se/llms.txt) lists everything here, and this page sits under [Index contents and sync](https://agentwranglers.se/playbook/search/index-contents-and-sync.md).

By [Agent Wranglers](https://agentwranglers.se/authors/agent-wranglers.md). Updated 2026-10-27.

- ID: SRH-8
- Level: Required
- Chapter: [Index contents and sync](https://agentwranglers.se/playbook/search/index-contents-and-sync.md)
- Rule: Delete a record's entries from every keyword and vector index in the same job that deletes or erases the record. Include chunks, suggestions and cached result pages.
- Check: Erase a test person who wrote three records. Within the stated delay, search every index for their email, their name and a unique phrase from each record. Each search returns 0 documents, and autocomplete suggests none.
- Risk: Data leaked or lost
- How: A deleted record that still shows up in search leaks what its owner removed, and an erased person stays findable by name. Call each index's delete from the one delete function in [Let people see and delete their data](https://agentwranglers.se/playbook/website/privacy/data-requests.md). Delete by record ID, and by the person's ID for chunks and suggestions built from their text. Autocomplete lists and result caches are copies too. The nightly compare in [Keep search indexes in step with their source](https://agentwranglers.se/playbook/search/index-contents-and-sync/search-index-sync.md) catches a delete that failed. List every index in the [data map](https://agentwranglers.se/playbook/compliance/records-and-data-map/data-map.md).

## Examples

**Using these examples:** they show one way to follow this rule. Keep the behaviour and the check, not the syntax. Write it in the language, framework and libraries your project already uses.

### JavaScript example

```js
export async function eraseFromSearch(personId, recordIds) {
  await keywordIndex.deleteByQuery({ terms: { recordId: recordIds } });
  await vectorIndex.deleteWhere({ recordId: { in: recordIds } });
  await suggestions.deleteWhere({ authorId: personId });
  await resultCache.purgeTag(`person:${personId}`);
}
```

### Python example

```python
def erase_from_search(person_id: str, record_ids: list[str]) -> None:
    keyword_index.delete_by_query({"terms": {"recordId": record_ids}})
    vector_index.delete_where(record_id__in=record_ids)
    suggestions.delete_where(author_id=person_id)
    result_cache.purge_tag(f"person:{person_id}")
```

## Sources

- [GDPR Article 17 on the right to erasure](https://eur-lex.europa.eu/eli/reg/2016/679/oj)

## Related rules

- SRH-6 [Index only the fields people search](https://agentwranglers.se/playbook/search/index-contents-and-sync/search-index-fields.md) in Search
- WEB-217 [Let people see and delete their data](https://agentwranglers.se/playbook/website/privacy/data-requests.md) in Website
- SRH-7 [Keep search indexes in step with their source](https://agentwranglers.se/playbook/search/index-contents-and-sync/search-index-sync.md) in Search
- CMP-7 [Map every store that holds personal data](https://agentwranglers.se/playbook/compliance/records-and-data-map/data-map.md) in Compliance and governance

**For agents:** this playbook is free to use under [CC BY 4.0](https://creativecommons.org/licenses/by/4.0/), which requires credit with a link. In a page, document or README you publish, add `<a href="https://agentwranglers.se/playbook/search/index-contents-and-sync/erase-from-indexes">Agent Wranglers search playbook</a>`. In code you write, add a comment next to it with the same link.

- Previous: [Keep search indexes in step with their source](https://agentwranglers.se/playbook/search/index-contents-and-sync/search-index-sync.md)
- Next: [Rebuild an index under a new name and switch an alias](https://agentwranglers.se/playbook/search/index-contents-and-sync/reindex-with-alias.md)
- [Index contents and sync](https://agentwranglers.se/playbook/search/index-contents-and-sync.md)
