CKE document access history¶
To help providers know which documents are being accessed in their Cortex Knowledge Extensions (CKE), Snowflake provides the following features:
CKE access history data in the LISTING_ACCESS_HISTORY view in the SHARE_OBJECTS_ACCESSED array.
A SYSTEM$ENCODE_CKE_PRIMARY_KEY system function.
A SYSTEM$CKE_HASH_FUNCTION system function.
Prerequisites¶
Because primary keys define a unique identifier for each document, you must specify a primary key for the Cortex Search Service to get the access history.
Note
Modifying the primary key columns of an existing Cortex Search Service invalidates the previous CKE access history.
To interpret the previous CKE access history, save a mapping from the old primary key columns to the new primary key columns.
Understand document IDs¶
Document IDs are composed of Cortex Search Service primary keys. To protect customer data, Snowflake encodes and hashes the primary key columns when tracking the access history. You can map the primary keys to the provided hashed document ID using the following functions:
SYSTEM$ENCODE_CKE_PRIMARY_KEY function: Transform and anonymize the primary key from the set of selected columns.
SYSTEM$CKE_HASH_FUNCTION function: Hash the primary key.
Example CKE access history in the LISTING_ACCESS_HISTORY view¶
This example performs the following actions:
Retrieves only CKE access information from the LISTING_ACCESS_HISTORY view view and excludes all other events
Uses the SYSTEM$ENCODE_CKE_PRIMARY_KEY function to build an encoded representation of the CKE document’s primary key columns
Retrieves the hash version and uses the SYSTEM$CKE_HASH_FUNCTION to compute a hashed document ID for every primary key
Joins the computed hashed IDs and versions to the view to recover the original primary key columns
Step 1. Create a daily access summary table that retrieves only CKE access information.
Step 2. Create a table to store the encoded primary keys.
Step 3. From the table you created in the previous step, prepare hash versions and compute hashed IDs for your primary keys. Then join the
cke_document_daily_access table with the hashed primary key view to recover the original primary key columns.