ALTER CORTEX SEARCH SERVICE
statementpartialAI & MLSuspends, resumes, or modifies the properties of an existing Cortex Search service.
Syntax
supportedpartialnot supportednot scored
ALTER CORTEX SEARCH SERVICE [ IF EXISTS ] <name>
{ SUSPEND | RESUME } [ { INDEXING | SERVING } ]
ALTER CORTEX SEARCH SERVICE [ IF EXISTS ] <name> REFRESH
ALTER CORTEX SEARCH SERVICE [ IF EXISTS ] <name> SET
[ TARGET_LAG = { '<num> { seconds | minutes | hours | days }' } ]
[ WAREHOUSE = <warehouse_name> ]
[ PRIMARY KEY = ( <col_name> [, ... ] ) ]
[ FULL_INDEX_BUILD_INTERVAL_DAYS = <num> ]
[ REQUEST_LOGGING = { TRUE | FALSE } ]
[ AUTO_SUSPEND = { <num_seconds> | NULL } ]
[ COMMENT = '<string_literal>' ]
ALTER CORTEX SEARCH SERVICE [ IF EXISTS ] <name> UNSET
[ PRIMARY KEY ]
ALTER CORTEX SEARCH SERVICE [ IF EXISTS ] <name> SET ATTRIBUTES ( <col_name> [, ... ] )
ALTER CORTEX SEARCH SERVICE [ IF EXISTS ] <name> UNSET ATTRIBUTES
ALTER CORTEX SEARCH SERVICE <name>
ADD SCORING PROFILE [ IF NOT EXISTS ] <profile_name>
<scoring_profile>
ALTER CORTEX SEARCH SERVICE <name>
DROP SCORING PROFILE [ IF EXISTS ] <profile_name>
ALTER CORTEX SEARCH SERVICE [ IF EXISTS ] <name> SET TAG <tag_name> = '<tag_value>' [ , <tag_name> = '<tag_value>' ... ]
ALTER CORTEX SEARCH SERVICE [ IF EXISTS ] <name> UNSET TAG <tag_name> [ , <tag_name> ... ]
Parameters
| Name | Required | Description |
|---|---|---|
name | Specifies the identifier for the Cortex Search service to alter. If the identifier contains spaces or special characters, the entire string must be enclosed in double quotes. Identifiers enclosed in double quotes are also case-sensitive. For more information, see Identifier requirements. | |
{ SUSPEND | RESUME } ... | Suspends or resumes the indexing, serving, or both for a Cortex Search service. You can specify one of the following keywords to indicate which layer to suspend or resume:
| |
REFRESH | Triggers a manual refresh of the Cortex Search Service. The indexing service immediately checks for changes to the source data and processes any new or changed rows. | |
SET ... | Sets one or more specified properties or parameters to set for the Cortex Search service: | |
TARGET_LAG = 'num { seconds | minutes | hours | days }' | Specifies the maximum amount of time that the Cortex Search service content should lag behind updates to the base tables specified in the source query. | |
WAREHOUSE = warehouse_name | Specifies the warehouse to use for running the source query, building the search index, and keeping it refreshed per the TARGET_LAG target. | |
FULL_INDEX_BUILD_INTERVAL_DAYS = num | Specifies the target interval, in days, between full index rebuilds for a Cortex Search service with primary keys defined. This property is only applicable to services that have primary keys set. Services with primary keys use an optimized refresh path where each refresh cycle (governed by TARGET_LAG) processes only the rows that changed since the last refresh, rather than re-embedding all data. Over time, these incremental updates accumulate fragmented index segments. A full index rebuild compacts these segments into a single optimized index. The rebuild does not re-embed unchanged data. This value is a soft target. Full index rebuilds may occur more frequently than the specified interval to optimize serving performance based on factors such as service target lag, change rate in the service source data, and overall service size. | |
REQUEST_LOGGING = \{ TRUE | FALSE \} | Enables or disables request logging for the Cortex Search Service. When enabled, the service records information about search requests, which you can query for monitoring and analysis purposes. For more information, see Monitor Cortex Search requests. Default: FALSE | |
AUTO_SUSPEND = { num_seconds | NULL } | Sets the number of seconds of query inactivity after which the service’s serving compute is automatically suspended. Affects serving only, not indexing. The service automatically resumes when it receives a query. Minimum: 1800 (30 minutes). Set to NULL to disable auto-suspend. For more information, see Auto-suspend serving on inactivity. | |
COMMENT = 'string_literal' | Adds a comment or overwrites an existing comment for the search service. | |
PRIMARY KEY = (column_name, column_name, ...) | Modifies the set of primary key columns for the Cortex Search service. The combination of values in the designated columns must be unique for each row; rows with duplicate primary key values are ignored in the resulting search index. Primary key columns must be of the TEXT data type. Changes to primary keys take effect after the next change to the source data. | |
UNSET ... | Unsets one or more specified properties or parameters for the Cortex Search service. | |
PRIMARY KEY | Removes any primary key columns that were previously set for the Cortex Search service. | |
SET ATTRIBUTES (col_name [, ...]) | Specifies the attribute (filter) columns for the Cortex Search service. Attribute columns enable filtering search results using the filter parameter in search queries. Column names must be present in the service source query and cannot be of the OBJECT type. Changes take effect after the next index refresh, as determined by the TARGET_LAG setting and the presence of changes in the underlying source data. To apply changes immediately, trigger a manual refresh using ALTER CORTEX SEARCH SERVICE ... REFRESH. | |
UNSET ATTRIBUTES | Removes all attribute columns from the Cortex Search service. Changes take effect after the next index refresh, as determined by the TARGET_LAG setting and the presence of changes in the underlying source data. To apply changes immediately, trigger a manual refresh using ALTER CORTEX SEARCH SERVICE ... REFRESH. | |
ADD SCORING PROFILE profile_name [ IF NOT EXISTS ] scoring_profile | Adds a named scoring profile to the Cortex Search service. Scoring profiles define custom ranking behavior for search results. For more information, see Named scoring profiles.
| |
DROP SCORING PROFILE [ IF EXISTS ] profile_name | Drops a named scoring profile from the Cortex Search service.
| |
SET TAG tag_name = 'tag_value' [ , tag_name = 'tag_value' ... ] | ||
TAG tag_name = 'tag_value' [ , tag_name = 'tag_value' , ... ] | Specifies the tag name and the tag string value. The tag value is always a string, and the maximum number of characters for the tag value is 256. For information about specifying tags in a statement, see Tag quotas. | |
UNSET TAG tag_name [ , tag_name ... ] | Specifies one or more tags to unset on the Cortex Search service: tag_name [ , tag_name ... ] To unset multiple properties or parameters with a single ALTER statement, separate each property or parameter with a comma. When unsetting a property or parameter, specify only the property or parameter name (unless the syntax above indicates that you should specify the value). Specifying the value returns an error. |
Usage notes
- Attention
- Customers should ensure that no personal data (other than for a User object), sensitive data, export-controlled data, or other regulated data is entered as metadata when using the Snowflake service. For more information, see Metadata fields in Snowflake.
- Cortex Search services have two distinct processes that can be in either the RUNNING or SUSPENDED state: INDEXING and SERVING.
- INDEXING is the target that indicates the indexing layer of the Cortex Search Service. When in the RUNNING state, changes in base tables referenced by the service’s source query will prompt refreshes of the materialized data stored as part of the search index. These refreshes incur cost in the form of warehouse compute and vector embeddings. When in the SUSPENDED state, changes in base tables will not trigger refreshes, nor will they be reflected in the queryable data of the Cortex Search Service. Note If indexing is suspended for longer than the data retention period of the source tables, the service may be unable to detect changes in the source data when indexing is resumed and could require recreation. For more information, see DATA_RETENTION_TIME_IN_DAYS.
- SERVING is the target that indicates the serving layer of the Cortex Search Service. This target must be in the RUNNING state for the service to be queryable. When in the suspended state, the Cortex Search Service will not incur billing in the form of Cortex Search’s serving costs.
- For detailed cost considerations, see Cost considerations.
- The INDEXING and SERVING layers of the Cortex Search Service can be managed independently. For instance, if SERVING is in the running state while INDEXING is suspended, you can still query the service. However, the service will not reflect any changes in the base data regardless of the TARGET_LAG until INDEXING is resumed and a refresh is completed successfully.
- Conversely, if INDEXING is running while SERVING is suspended, the index will continue to refresh. When SERVING is resumed, the loaded index that becomes queryable will reflect the most up-to-date source data.
- When neither the SERVING nor INDEXING keywords are specified, both targets will be impacted by the specified action.
- When you manually refresh a Cortex Search Service, the service immediately checks for changes in its source data and updates the index as needed. Trigger a manual refresh of your Cortex Search Service when you need the most up-to-date results possible — for example, when you have just added or updated important documents and want these to be available immediately to users. You can also use a manual refresh to ensure that results are always current at specific times, such as at the start of business.
- You can trigger a manual refresh of a Cortex Search Service using the ALTER CORTEX SEARCH SERVICE … REFRESH command or in Snowsight.
- Altering the primary key columns of a Cortex Search Service affects only future refreshes. That is, changes to primary keys go into effect after the next change to the source data.
Access Control Requirements
Privilege | Object OWNERSHIP | Cortex Search service you want to modify any properties on. OPERATE | Cortex Search service you want to perform one of the following on: Suspend search indexing Resume search indexing Refresh search index Set or change query warehouse Set or change target lag APPLY | Enables setting a tag on a Cortex Search service. Operating on an object in a schema requires at least one privilege on the parent database and at least one privilege on the parent schema. For instructions on creating a custom role with a specified set of privileges, see Creating custom roles. For general information about roles and privilege grants for performing SQL actions on securable objects, see Overview of Access Control.
Known gaps
- IF EXISTS, WAREHOUSE, REQUEST_LOGGING, AUTO_SUSPEND, PRIMARY KEY, SET ATTRIBUTES, UNSET ATTRIBUTES, IF NOT EXISTS, UNSET TAG, REQUEST_LOGGING values TRUE / FALSE, AUTO_SUSPEND = NULL are not exercised by any test