ALTER CORTEX SEARCH SERVICE

statementpartialAI & ML

docs.snowflake.com ↗

Object: CORTEX SEARCH SERVICE

Suspends, 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

NameRequiredDescription
nameSpecifies 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:
  • INDEXING — The target that indicates the indexing layer of the Cortex Search Service. For more details, see Usage Notes.
  • SERVING — The target that indicates the serving layer of the Cortex Search Service. For more details, see Usage Notes. If you do not specify either keyword, both the indexing and serving layers are suspended or resumed. The OPERATE privilege is required to suspend or resume a Cortex Search service. To suspend serving automatically after a period of inactivity instead of manually, use the AUTO_SUSPEND property described in the SET clause below. For more information, see Auto-suspend serving on inactivity.
REFRESHTriggers 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_nameSpecifies 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 = numSpecifies 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 KEYRemoves 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 ATTRIBUTESRemoves 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_profileAdds 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.
  • profile_name — Specifies the name of the scoring profile to add. If a profile with the specified name already exists, an error occurs unless you specify IF NOT EXISTS. To modify an existing profile, drop it using DROP SCORING PROFILE first.
  • scoring_profile — The scoring profile definition in JSON string format. The schema is the same as a scoring configuration specified directly in a search query using the scoring_config parameter. See Numeric boosts and time decays for syntax and examples.
DROP SCORING PROFILE [ IF EXISTS ] profile_nameDrops a named scoring profile from the Cortex Search service.
  • profile_name — The name of the scoring profile to drop.
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

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

Parts not fully supported, and recorded divergences from Snowflake.