Agent Wranglers

SRH-8Required

Remove erased records from every index

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.

How to do it

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. 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 catches a delete that failed. List every index in the data map.

Examples

JavaScript example

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

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}")

How to 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.

Sources

For agents: this playbook is free to use under CC 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.