semantic search examples

Example 1: Find the Top Key Phrases in a Specific Document

The following example retrieves the top 10 key phrases from the document specified by the @DocumentId variable in the Document column of the Production.Document table of the AdventureWorks sample database. The @DocumentId variable represents a value from the key column of the full-text index.

SELECT TOP(10) KEYP_TBL.keyphrase
FROM SEMANTICKEYPHRASETABLE
    (
    Production.Document,
    Document,
    @DocumentId
    ) AS KEYP_TBL
ORDER BY KEYP_TBL.score DESC;
GO


Example 2: Find the Top Documents that Contain a Specific Key Phrase

The following example retrieves the top 25 documents that contain the key phrase “Bracket” from the Document column of the Production.Document table of the AdventureWorks sample database.

SELECT TOP (25) DOC_TBL.DocumentID, DOC_TBL.DocumentSummary
FROM Production.Document AS DOC_TBL
    INNER JOIN SEMANTICKEYPHRASETABLE
    (
    Production.Document,
    Document
    ) AS KEYP_TBL
ON DOC_TBL.DocumentID = KEYP_TBL.document_key
WHERE KEYP_TBL.keyphrase = 'Bracket'
ORDER BY KEYP_TBL.Score DESC;
GO


Example 3: Find the Top Documents That Are Similar to Another Document

The following example retrieves the top 10 candidates who are similar to the candidate specified by @CandidateID from the HumanResources.JobCandidate table in the AdventureWorks2012 sample database.

SELECT TOP(10) KEY_TBL.matched_document_key AS Candidate_ID
FROM SEMANTICSIMILARITYTABLE
    (
    HumanResources.JobCandidate,
    Resume,
    @CandidateID
    ) AS KEY_TBL
ORDER BY KEY_TBL.score DESC;
GO


Example 4: Find the Top Key Phrases That Are Similar between Documents

The following example retrieves the 5 key phrases that have the highest similarity score between the specified candidates in HumanResources.JobCandidate table of the AdventureWorks2012 sample database.

SELECT TOP(5) KEY_TBL.keyphrase, KEY_TBL.score
FROM SEMANTICSIMILARITYDETAILSTABLE
    (
    HumanResources.JobCandidate,
    Resume, @CandidateID,
    Resume, @MatchedID
    ) AS KEY_TBL
ORDER BY KEY_TBL.score DESC;
GO


你可能感兴趣的:(example)