semanticsimilaritydetailstable (Transact-SQL)semanticsimilaritydetailstable (Transact-SQL)
适用于:Applies to: SQL ServerSQL Server(所有支持的版本)
SQL ServerSQL Server (all supported versions)
SQL ServerSQL Server(所有支持的版本)
SQL ServerSQL Server (all supported versions)
返回一个表,该表包含其内容在语义上相似的两个文档(源文档和匹配的文档)共有的关键短语的零个、一个或多个行。Returns a table of zero, one, or more rows of key phrases that are common across two documents (a source document and a matched document) whose content is semantically similar.
此行集函数可在 SELECT 语句的 FROM 子句中引用This rowset function can be referenced in the FROM clause of a SELECT statement
Transact-SQL 语法约定
Transact-SQL Syntax Conventions
语法Syntax
SEMANTICSIMILARITYDETAILSTABLE
(
table,
source_column,
source_key,
matched_column,
matched_key
)
参数Arguments
tabletable
启用全文和语义索引的表的名称。Is the name of a table that has full-text and semantic indexing enabled.
此名称可由 1 到 4 个部分组成,但不允许使用远程服务器名称。This name can be a one to four part name, but a remote server name is not allowed.
source_columnsource_column
源行中包含要比较相似性的内容的列的名称。Name of the column in the source row that contains the content to be compared for similarity.
source_keysource_key
表示源文档的行的唯一键。The unique key that represents the row of the source document.
此键将尽可能隐式转换为源表中的全文唯一键的类型。This key is implicitly converted to the type of the full-text unique key in the source table whenever possible. 可以将此键指定为一个常量或变量,但不能是表达式或标量子查询的结果。The key can be specified as a constant or a variable, but cannot be an expression or the result of a scalar sub-query. 如果指定了无效键,则不返回任何行。If an invalid key is specified, no rows are returned.
matched_columnmatched_column
匹配的行中包含要比较相似性的内容的列的名称。Name of the column in the matched row that contains the content to be compared for similarity.
matched_keymatched_key
表示匹配文档的行的唯一键。The unique key that represents the row of the matched document.
此键将尽可能隐式转换为源表中的全文唯一键的类型。This key is implicitly converted to the type of the full-text unique key in the source table whenever possible. 可以将此键指定为一个常量或变量,但不能是表达式或标量子查询的结果。The key can be specified as a constant or a variable, but cannot be an expression or the result of a scalar sub-query.
返回的表Table Returned
下表介绍此行集函数返回的关键短语的信息。The following table describes the information about key phrases that this rowset function returns.
Column_nameColumn_name | 类型Type | 说明Description |
---|---|---|
关键短语keyphrase | NVARCHARNVARCHAR | 在源文档和匹配文档之间促进相似性的关键短语。The key phrase that contributes to the similarity between source document and the matched document. |
分值score | REALREAL | 一个相对值,用来表示此关键短语与两篇文档间相似的所有其他关键短语的关系。A relative value for this key phrase in its relationship to all the other key phrases that are similar between the 2 documents. 该值是范围 [0.0, 1.0] 中的小数值,较高的得分表示较高权重,1.0 是最理想的得分。The value is a fractional decimal value in the range of [0.0, 1.0] where a higher score represents a higher weighting and 1.0 is the perfect score. |
一般备注General Remarks
有关详细信息,请参阅 通过语义搜索查找相似和相关文档。For more information, see Find Similar and Related Documents with Semantic Search.
元数据Metadata
有关语义相似性的提取和填充的信息和状态,请查询以下动态管理视图:For information and status about semantic similarity extraction and population, query the following dynamic management views:
安全性Security
权限Permissions
需要对创建全文和语义搜索所基于的基表具有 SELECT 权限。Requires SELECT permissions on the base table on which the full-text and semantic indexes were created.
示例Examples
下面的示例检索5个关键短语,该短语在 AdventureWorks2012 示例数据库的 HumanResources humanresources.jobcandidate 表中指定的候选项之间具有最高相似性分数。The following example retrieves the 5 key phrases that had the highest similarity score between the specified candidates in HumanResources.JobCandidate table of the AdventureWorks2012 sample database. @CandidateId和 @MatchedID 变量表示全文索引的键列中的值。The @CandidateId and @MatchedID variables represent values from the key column of the full-text index.
SELECT TOP(5) KEY_TBL.keyphrase, KEY_TBL.score
FROMSEMANTICSIMILARITYDETAILSTABLE
(
HumanResources.JobCandidate,
Resume, @CandidateID,
Resume, @MatchedID
) AS KEY_TBL
ORDER BY KEY_TBL.score DESC;