search_services
Creates, updates, deletes, gets or lists a search_services
resource.
Overview
Name | search_services |
Type | Resource |
Id | snowflake.cortex_search_service.search_services |
Fields
The following fields are returned by SELECT
queries:
- list_cortex_search_services
- fetch_cortex_search_service
A Snowflake cortex search service object.
Name | Datatype | Description |
---|---|---|
name | string | Specifies the name for the cortex search service, must be unique for the schema in which the cortex search service is created |
database_name | string | Database in which the cortex search service is stored |
schema_name | string | Schema in which the cortex search service is stored |
attribute_columns | array | Specifies the attribute columns, which can be referenced in filters in search queries to the cortex search service. |
columns | array | Specifies all columns included in the cortex search service and that can be returned in search queries. |
comment | string | Specifies a comment for the cortex search service |
created_on | string (date-time) | Date and time when the cortex search service was created. |
data_timestamp | string (date-time) | Date and time as of which data existent in base tables is now serving. |
definition | string | Specifies the definition (source query) used to create the cortex search service (example: SELECT col1, col2 FROM foo) |
indexing_error | string | Error encountered during the latest indexing pipeline of the cortex search service, if any. |
indexing_state | string | |
search_column | string | Specifies the name of the search column for the cortex search service. |
serving_data_bytes | integer (int64) | Size of the serving index, in bytes. |
serving_state | string | |
source_data_num_rows | integer (int64) | Number of rows in the materialized source data feeding into the cortex search service. |
target_lag | object | Specifies the schedule for periodically refreshing the dynamic table. |
warehouse | string | Specifies the name of the warehouse that provides the compute resources for refreshing the cortex search service (example: test_wh) |
A Snowflake cortex search service object.
Name | Datatype | Description |
---|---|---|
name | string | Specifies the name for the cortex search service, must be unique for the schema in which the cortex search service is created |
database_name | string | Database in which the cortex search service is stored |
schema_name | string | Schema in which the cortex search service is stored |
attribute_columns | array | Specifies the attribute columns, which can be referenced in filters in search queries to the cortex search service. |
columns | array | Specifies all columns included in the cortex search service and that can be returned in search queries. |
comment | string | Specifies a comment for the cortex search service |
created_on | string (date-time) | Date and time when the cortex search service was created. |
data_timestamp | string (date-time) | Date and time as of which data existent in base tables is now serving. |
definition | string | Specifies the definition (source query) used to create the cortex search service (example: SELECT col1, col2 FROM foo) |
indexing_error | string | Error encountered during the latest indexing pipeline of the cortex search service, if any. |
indexing_state | string | |
search_column | string | Specifies the name of the search column for the cortex search service. |
serving_data_bytes | integer (int64) | Size of the serving index, in bytes. |
serving_state | string | |
source_data_num_rows | integer (int64) | Number of rows in the materialized source data feeding into the cortex search service. |
target_lag | object | Specifies the schedule for periodically refreshing the dynamic table. |
warehouse | string | Specifies the name of the warehouse that provides the compute resources for refreshing the cortex search service (example: test_wh) |
Methods
The following methods are available for this resource:
Name | Accessible by | Required Params | Optional Params | Description |
---|---|---|---|---|
list_cortex_search_services | select | database_name , schema_name , endpoint | like , fromName , showLimit | Lists the cortex search services under the database and schema. |
fetch_cortex_search_service | select | database_name , schema_name , name , endpoint | Fetch a Cortex Search Service. | |
create_cortex_search_service | insert | database_name , schema_name , endpoint | createMode | Create a cortex search service, with standard create modifiers as query parameters. See the Cortex Search Service component definition for what is required to be provided in the request body. |
delete_cortex_search_service | delete | database_name , schema_name , name , endpoint | ifExists | Delete a cortex search service with the given name. If ifExists is used, the operation will succeed even if the object does not exist. Otherwise, there will be a failure if the drop is unsuccessful. |
query_cortex_search_service | exec | database_name , schema_name , service_name , endpoint | Query a Cortex Search Service to get search results. | |
suspend_cortex_search_service | exec | database_name , schema_name , name , endpoint | ifExists , target | Suspends one or both of the indexing or serving targets of a cortex search service. |
resume_cortex_search_service | exec | database_name , schema_name , name , endpoint | ifExists , target | Resume the cortex search service |
Parameters
Parameters can be passed in the WHERE
clause of a query. Check the Methods section to see which parameters are required or optional for each operation.
Name | Datatype | Description |
---|---|---|
database_name | string | Identifier (i.e. name) for the database to which the resource belongs. You can use the /api/v2/databases GET request to get a list of available databases. |
endpoint | string | Organization and Account Name (default: orgid-acctid) |
name | string | Identifier (i.e. name) for the resource. |
schema_name | string | Identifier (i.e. name) for the schema to which the resource belongs. You can use the /api/v2/databases/{database}/schemas GET request to get a list of available schemas for the specified database. |
service_name | string | The name of the Cortex Search Service. |
createMode | string | Query parameter allowing support for different modes of resource creation. Possible values include: - errorIfExists : Throws an error if you try to create a resource that already exists. - orReplace : Automatically replaces the existing resource with the current one. - ifNotExists : Creates a new resource when an alter is requested for a non-existent resource. |
fromName | string | Query parameter to enable fetching rows only following the first row whose object name matches the specified string. Case-sensitive and does not have to be the full name. |
ifExists | boolean | Query parameter that specifies how to handle the request for a resource that does not exist: - true : The endpoint does not throw an error if the resource does not exist. It returns a 200 success response, but does not take any action on the resource. - false : The endpoint throws an error if the resource doesn't exist. |
like | string | Query parameter to filter the command output by resource name. Uses case-insensitive pattern matching, with support for SQL wildcard characters. |
showLimit | integer | Query parameter to limit the maximum number of rows returned by a command. |
target | string | Query parameter that identifies the target to which suspension or resumption of the cortex search service should be applied. |
SELECT
examples
- list_cortex_search_services
- fetch_cortex_search_service
Lists the cortex search services under the database and schema.
SELECT
name,
database_name,
schema_name,
attribute_columns,
columns,
comment,
created_on,
data_timestamp,
definition,
indexing_error,
indexing_state,
search_column,
serving_data_bytes,
serving_state,
source_data_num_rows,
target_lag,
warehouse
FROM snowflake.cortex_search_service.search_services
WHERE database_name = '{{ database_name }}' -- required
AND schema_name = '{{ schema_name }}' -- required
AND endpoint = '{{ endpoint }}' -- required
AND like = '{{ like }}'
AND fromName = '{{ fromName }}'
AND showLimit = '{{ showLimit }}';
Fetch a Cortex Search Service.
SELECT
name,
database_name,
schema_name,
attribute_columns,
columns,
comment,
created_on,
data_timestamp,
definition,
indexing_error,
indexing_state,
search_column,
serving_data_bytes,
serving_state,
source_data_num_rows,
target_lag,
warehouse
FROM snowflake.cortex_search_service.search_services
WHERE database_name = '{{ database_name }}' -- required
AND schema_name = '{{ schema_name }}' -- required
AND name = '{{ name }}' -- required
AND endpoint = '{{ endpoint }}' -- required;
INSERT
examples
- create_cortex_search_service
- Manifest
Create a cortex search service, with standard create modifiers as query parameters. See the Cortex Search Service component definition for what is required to be provided in the request body.
INSERT INTO snowflake.cortex_search_service.search_services (
data__name,
data__search_column,
data__columns,
data__attribute_columns,
data__target_lag,
data__warehouse,
data__definition,
data__comment,
data__indexing_state,
data__serving_state,
database_name,
schema_name,
endpoint,
createMode
)
SELECT
'{{ name }}' --required,
'{{ search_column }}' --required,
'{{ columns }}',
'{{ attribute_columns }}',
'{{ target_lag }}' --required,
'{{ warehouse }}' --required,
'{{ definition }}' --required,
'{{ comment }}',
'{{ indexing_state }}',
'{{ serving_state }}',
'{{ database_name }}',
'{{ schema_name }}',
'{{ endpoint }}',
'{{ createMode }}'
;
# Description fields are for documentation purposes
- name: search_services
props:
- name: database_name
value: string
description: Required parameter for the search_services resource.
- name: schema_name
value: string
description: Required parameter for the search_services resource.
- name: endpoint
value: string
description: Required parameter for the search_services resource.
- name: name
value: string
description: >
Specifies the name for the cortex search service, must be unique for the schema in which the cortex search service is created
- name: search_column
value: string
description: >
Specifies the name of the search column for the cortex search service.
- name: columns
value: array
description: >
Specifies all columns included in the cortex search service and that can be returned in search queries.
- name: attribute_columns
value: array
description: >
Specifies the attribute columns, which can be referenced in filters in search queries to the cortex search service.
- name: target_lag
value: object
description: >
Specifies the schedule for periodically refreshing the dynamic table.
- name: warehouse
value: string
description: >
Specifies the name of the warehouse that provides the compute resources for refreshing the cortex search service
- name: definition
value: string
description: >
Specifies the definition (source query) used to create the cortex search service
- name: comment
value: string
description: >
Specifies a comment for the cortex search service
- name: indexing_state
value: string
valid_values: ['ACTIVE', 'SUSPENDED', 'INITIALIZING']
- name: serving_state
value: string
valid_values: ['ACTIVE', 'SUSPENDED', 'INITIALIZING']
- name: createMode
value: string
description: Query parameter allowing support for different modes of resource creation. Possible values include: - `errorIfExists`: Throws an error if you try to create a resource that already exists. - `orReplace`: Automatically replaces the existing resource with the current one. - `ifNotExists`: Creates a new resource when an alter is requested for a non-existent resource.
DELETE
examples
- delete_cortex_search_service
Delete a cortex search service with the given name. If ifExists is used, the operation will succeed even if the object does not exist. Otherwise, there will be a failure if the drop is unsuccessful.
DELETE FROM snowflake.cortex_search_service.search_services
WHERE database_name = '{{ database_name }}' --required
AND schema_name = '{{ schema_name }}' --required
AND name = '{{ name }}' --required
AND endpoint = '{{ endpoint }}' --required
AND ifExists = '{{ ifExists }}';
Lifecycle Methods
- query_cortex_search_service
- suspend_cortex_search_service
- resume_cortex_search_service
Query a Cortex Search Service to get search results.
EXEC snowflake.cortex_search_service.search_services.query_cortex_search_service
@database_name='{{ database_name }}' --required,
@schema_name='{{ schema_name }}' --required,
@service_name='{{ service_name }}' --required,
@endpoint='{{ endpoint }}' --required
@@json=
'{
"query": "{{ query }}",
"multi_index_query": "{{ multi_index_query }}",
"columns": "{{ columns }}",
"filter": "{{ filter }}",
"limit": {{ limit }},
"scoring_config": "{{ scoring_config }}",
"experimental": "{{ experimental }}"
}';
Suspends one or both of the indexing or serving targets of a cortex search service.
EXEC snowflake.cortex_search_service.search_services.suspend_cortex_search_service
@database_name='{{ database_name }}' --required,
@schema_name='{{ schema_name }}' --required,
@name='{{ name }}' --required,
@endpoint='{{ endpoint }}' --required,
@ifExists={{ ifExists }},
@target='{{ target }}';
Resume the cortex search service
EXEC snowflake.cortex_search_service.search_services.resume_cortex_search_service
@database_name='{{ database_name }}' --required,
@schema_name='{{ schema_name }}' --required,
@name='{{ name }}' --required,
@endpoint='{{ endpoint }}' --required,
@ifExists={{ ifExists }},
@target='{{ target }}';