Search Agent query examples
Search Agent query examples
You can retrieve Search Agent data using SQL queries to build your own reports and analyses. Search Agent data is stored in the ANSWERING schema of the CORE data model in Snowflake. You can access the schema through a reader account or a data share.
Query examples
The following sample queries are a starting point for querying Search Agent data.
|
|
Note
The sample queries retrieve the |
Retrieve answers with their query expression
Use this query to retrieve Search Agent answers alongside the query that triggered them. This is the most common starting point for Search Agent reporting.
SELECT
A.ORGANIZATION_ID
, A.CONVERSATION_ID
, A.ANSWER_XID
, I.QUERY_EXPRESSION
, A.IS_QUERY_ANSWERED
, A.ANSWER
FROM COVEO_CORE_MODEL_V001.COMMON.INSIGHTS I
JOIN COVEO_CORE_MODEL_V001.ANSWERING.ANSWERS A
ON I.ORGANIZATION_ID = A.ORGANIZATION_ID
AND I.INSIGHT_ID = A.ANSWER_ID
AND I.INSIGHT_DATE = A.ANSWER_DATE
WHERE A.ANSWER_SOURCE = 'search_agent'
AND I.INSIGHT_DATE BETWEEN '<START_DATE>' AND '<END_DATE>'
Where you replace:
-
<START_DATE>and<END_DATE>with date values, formatted asYYYY-MM-DD. A conversation can remain active for up to 48 hours, so use a date range that covers the full period of interest.
Retrieve answers with conversation context
Use this query to retrieve all turns from a specific conversation, identified by its CONVERSATION_XID.
SELECT
A.ORGANIZATION_ID
, C.CONVERSATION_XID
, A.ANSWER_XID
, I.QUERY_EXPRESSION
, A.IS_QUERY_ANSWERED
, A.ANSWER
FROM COVEO_CORE_MODEL_V001.COMMON.INSIGHTS I
JOIN COVEO_CORE_MODEL_V001.ANSWERING.ANSWERS A
ON I.ORGANIZATION_ID = A.ORGANIZATION_ID
AND I.INSIGHT_ID = A.ANSWER_ID
AND I.INSIGHT_DATE = A.ANSWER_DATE
JOIN COVEO_CORE_MODEL_V001.ANSWERING.CONVERSATIONS C
ON A.ORGANIZATION_ID = C.ORGANIZATION_ID
AND A.CONVERSATION_ID = C.CONVERSATION_ID
WHERE A.ANSWER_SOURCE = 'search_agent'
AND I.INSIGHT_DATE BETWEEN '<START_DATE>' AND '<END_DATE>'
AND C.CONVERSATION_XID = '<CONVERSATION_XID>'
Where you replace:
-
<START_DATE>and<END_DATE>with date values, formatted asYYYY-MM-DD. A conversation can remain active for up to 48 hours, so use a date range that covers the full period of interest. -
<CONVERSATION_XID>with the external conversation identifier from the Agent API (for example,conv_00991f9b-5fc5-43a3-a516-13fff1ebdfa0).