SEMANTICSIMILARITYDETAILSTABLE
SEMANTICSIMILARITYDETAILSTABLE is an SQL function that provides detailed results of a semantic similarity search operation. It returns a table that contains rows corresponding to the matched columns of the target table that was used in the SEMANTICSIMILARITYTABLE function. This way, it can be utilized to explore more details related to rows returned by the SEMANTICSIMILARITYTABLE function. It is particularly useful when the user needs to understand why certain rows were returned based on semantic similarity.
SEMANTICSIMILARITYDETAILSTABLE( table, { column | (column) }, source_key )
- table: The name of the table from which the semantics similarity details are to be fetched.
- column: The specific column in the ‘table’ parameter whose values are to be compared with the ‘source_key’ to compute semantic similarity. Multiple columns can be passed in a comma-separated parenthesis format.
- source_key: The unique ID of a specific row in the ‘column’ whose semantic similarity is to be compared with other rows.
Example
Output
Explanation
Here, we created a table ‘TestTable’ and inserted some data. Using SEMANTICSIMILARITYDETAILSTABLE
, we are asking SQL Server to return us semantic similarity details for the document in ‘TestTable’ that contains ‘1’ as its ID. The function returns a table containing detailed information about semantic similarity between the provided document and all other documents in the semantic index. The result will have keys, matched rank, matched by, and similarity score.