---
sourceDocument: Zurich ServiceNow AI Platform Administration
sourceDocumentLink: https://www.servicenow.com/docs/r/zurich/platform-administration

 Release :

    - zurich

ft:locale :

    - en-US

ft:publication_title :

    - Zurich ServiceNow AI Platform Administration

ft:clusterId :

    - platadm

bundleId :

    - platadm

workflow :

    - Platform


---

# Purge stale records from the index

# Purge stale records from the AI Search index {#ariaid-title1}

* Release version: Zurich
* 
* Updated July 31, 2025
* 
* ![](https://www.servicenow.com/docs/portal-asset/ico-clock) 1 minute to read

Execute a scheduled job to delete stale records from the AI Search index.

## Before you begin

Role required: admin  
Note:  
If the glide.script_processor.admin system property's value has been changed from the default value, you need the role specified by that property value. For details on this property value and its effects, see [Restrict access to background script \[Updated in Security Center 1.3 and 2.0\]](https://www.servicenow.com/docs/access?context=sc-restrict-access-to-background-script&version=zurich&pubname=zurich-platform-security&ft:locale=en-US).

## About this task

If either of these conditions is satisfied for a record in the AI Search index, AI Search marks the record as stale.

* The time since the record's last update exceeds the age limit from its indexed source's retention policy
* The record no longer satisfies the filter conditions defined for its indexed source

{#purge-stale-records-ais-index__ul_znh_qcy_brb} AI Search automatically purges stale records from the index daily. Administrators can purge records manually by running a background script.

For more information on running background scripts, see [Scripts - Background module](https://www.servicenow.com/docs/access?context=c_ScriptsBackground&version=zurich&pubname=zurich-api-reference&ft:locale=en-US).

## Procedure

1. Navigate to AllSystem DefinitionScripts - Background.  
   Note:  
   If the glide.script_processor.admin system property's value is set to security_admin, you must elevate to that privileged role to access this module. For more information on elevating privileges, see [Elevated privilege roles](https://www.servicenow.com/docs/access?context=c_ElevatedPrivilege&version=zurich&pubname=zurich-platform-security&ft:locale=en-US).
2. In the Run script (JavaScript executed on server) text field, enter one of the following background scripts.
   * To purge stale records indexed from a specific table, enter this script, replacing `TABLE_NAME` with the name of your chosen table:

         new sn_ais.IndexEvent().purgeFilteredDocuments('TABLE_NAME');

     For example, to purge all stale records indexed from the Knowledge Table indexed source, replace `TABLE_NAME` with <kbd class="ph userinput">kb_knowledge</kbd> in the script.
   * To purge all stale records in the index, regardless of which table they were indexed from, enter this script:

         new sn_ais.IndexEvent().purgeFilteredDocuments();

   {#purge-stale-records-ais-index__choices_b1j_kr2_3cc}
3. Select Run script.  
   The script creates an event that the index handler processes, so the script completes without blocking on completion of the purge job.

## Result

The background script executes, deleting stale records from the AI Search index.

*[\>]: and then


