Manual segment data model and sync behavior
Summarize
Summary of Manual Segment Data Model and Sync Behavior
Manual segments in ServiceNow use a two-table data model that separates configuration from runtime data to optimize search performance while maintaining a single source of truth. Theconfiguration table(snquerygensegmenttableconfig) stores segment definitions created and maintained by administrators. Theruntime table(snquerygensegment) is automatically synchronized and queried during search operations. This architecture ensures that segment configurations are consistently applied without manual synchronization.
Show less
Key Features
- Configuration Table Fields: Defines manual segments with key fields like
tablename(target table),name(user-friendly segment name),description(optional clarifications),filter(encoded query for segment conditions), andactive(enables or disables the segment). - Synced Runtime Table: Automatically updated via business rules and scheduled jobs, the runtime table contains fields copied from the configuration and references to the semantic layer entity, used for efficient search queries.
- Automatic Synchronization: Occurs asynchronously on configuration insert/update, entity insert/update, and via a weekly scheduled job. Segments are only active in runtime if both the segment configuration and referenced entity are active.
- Activation and Deactivation: Segments are activated or deactivated based on configuration status and entity activity. Deactivated segments are excluded from search results but remain in the system for easy reactivation.
- Access Control: Strict ACLs prevent direct editing of the runtime table to maintain configuration integrity. All changes must be made on the configuration table.
- Filter Length Management: Although filters can be up to 4,000 characters, a system property defaults to 2,000 characters, truncating longer filters in LLM prompts. It is recommended to keep filters concise or split complex segments into multiple focused ones.
- Domain Separation Support: Manual segments inherit domain context when domain separation is enabled, ensuring users only see segments relevant to their domain.
Practical Benefits for ServiceNow Customers
- Enables precise, administrator-defined segmentation of data for semantic search, improving the relevance of search results.
- Ensures reliable synchronization between segment definitions and runtime search data without manual intervention.
- Maintains data integrity and security with ACLs that restrict direct runtime table modifications.
- Supports domain separation for multi-domain environments, aligning segment visibility with user context.
- Provides flexibility to manage complex segment conditions efficiently by recommending concise filters or multiple segments.
Manual segments use a two-table data model with automatic synchronization between the configuration table and the runtime table used for search operations.
Data model overview
Manual segments use a two-table architecture that separates configuration from runtime data. This design ensures that the configuration table remains the single source of truth while the runtime table is optimized for search performance.
- configuration table: sn_query_gen_segment_table_config
- This is where you define manual segments. Each record represents one segment configuration that administrators create and maintain.
- Synced table: sn_query_gen_segment
- You do not write to this table directly. When a manual segment config is created or updated, a business rule automatically syncs it into this table, which is queried at search time.
Configuration table fields
The sn_query_gen_segment_table_configuration table contains the following fields for defining manual segments:
| Field | Column Name | Max Length | Required | Purpose |
|---|---|---|---|---|
| Table Name | table_name | — | Yes | The table (entity) the segment applies to. Must have an active entity in the semantic layer. |
| Name | name | 255 chars | Yes | User-friendly name that the LLM matches against during semantic search. |
| Description | description | 4,000 chars | No | Optional clarification using commonly-used terms. Helps the LLM understand when to apply the segment. |
| Filter | filter | 4,000 chars | Yes | Encoded query defining the segment's filter conditions. Uses the condition builder (v2). |
| Active | active | — | No | Defaults to true. When false, the segment is deactivated and excluded from search. |
Synced table fields
The sn_query_gen_segment table contains the runtime data used for search operations:
| Field | Source |
|---|---|
| name | Copied from manual segment config |
| description | Copied from manual segment config |
| filter | Copied from manual segment config |
| table | From table_name |
| entity | Resolved reference to sn_query_gen_entity |
| source_table | Always sn_query_gen_segment_table_config |
| source_id | Sys_id of the manual segment config record |
| active | manual_segment.active AND entity.active |
Sync behavior
Manual segments are synced automatically between the configuration and runtime tables. You do not need to trigger synchronization manually.
| Trigger | When | What Happens |
|---|---|---|
| Business rule on config | Insert or update on sn_query_gen_segment_table_config | Syncs the individual record into sn_query_gen_segment (async) |
| Entity insert/update | When an entity is created or updated with active=true | Re-syncs all segments (including manual) for that entity |
| Weekly scheduled job | Saturdays at midnight | Full sync of all 6 segment sources; cleanup of orphaned records |
During sync, a manual segment is eligible if:
- active = true on the config record
- The referenced table has an active entity in sn_query_gen_entity
If either condition is not met, the synced segment is deactivated (not deleted).
Activation and deactivation
A synced segment's active status is: manual_segment.active AND entity.active.
| Event | Result |
|---|---|
| Manual segment config active → false | Synced segment deactivated |
| Manual segment config active → true | Synced segment reactivated (if entity is also active) |
| Entity active → false | All segments for that entity deactivated |
| Manual segment config deleted | Synced segment deleted |
| Entity deleted | Orphaned segments cleaned up by scheduled job |
Deactivated segments are excluded from search results.
ACL protections
The synced segment table has strict ACLs so that the configuration table remains the single source of truth:
- Create: Blocked (admin_overrides = false) — segments can only be created via sync
- Write to name: Blocked — must be changed on the config record
- Write to description: Blocked — must be changed on the config record
Filter length considerations
While the filter field supports up to 4,000 characters, the system property sn_query_gen.segments.max_filter_length defaults to 2,000. Filters longer than this threshold are truncated when included in the LLM prompt.
Domain separation
Manual segments support domain separation. When creating a segment config record with a specific sys_domain, the synced segment inherits that domain. At search time, segments are filtered by the user's domain context.
If domain separation is not enabled on your instance, this field is inactive and can be ignored.