Regenerate the text index for a single record

  • Release version: Yokohama
  • Updated January 30, 2025
  • 2 minutes to read
  • Update the text search index for a single record. Use this approach to quickly verify whether text indexing is the cause of a search issue without rebuilding the full text index for an entire table.

    Before you begin

    Identify the following:
    • A search term that doesn't return the expected results
    • A record containing the identified search term that isn't returned when searching for the term
    • The table that includes the identified record

    The identified table must already be configured for indexing and searching. For details on this configuration process, see Configure a table for indexing and searching.

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

    About this task

    This reindexing method rebuilds the text search index for a single record. It takes less time than rebuilding the text index for all records in a table.

    You can use this method to quickly determine whether text indexing is the cause of a search issue. Doing so avoids the delay associated with rebuilding the entire table's text search index.

    Procedure

    1. Copy the sys_id for the identified record by selecting Copy sys_id from its context menu.
    2. Navigate to All > System Definition > Scripts - 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.
    3. In the Run script (JavaScript executed on server) text field, enter the following script, replacing TABLE_NAME with the name of the table containing the identified record and SYS_ID with the record's sys_id that you copied in step 1:
      var gr = new GlideRecord('TABLE_NAME');
      gr.get('SYS_ID');
      gs.eventQueue("text_index", gr, '[TABLE_NAME]','update','text_index');
    4. Select Run script.
      The script creates a text_index update event for the specified table in the text_index queue.
    5. Navigate to All > System Policy > Events > Event Log and wait for the new text_index update event's state to change to processed.
      To find the new event, you can apply a [Name][contains][text_index] filter and sort the Event list view by Created date/time in descending (z to a) order.

    Result

    The system updates the text index for the specified record in the specified table.

    What to do next

    Repeat your sample search. If this search returns the identified record, you may want to update the text index for the entire table that contains that record. For details, see Regenerate a text index for a table.