SQL Server Full-Text Search for exact match with fallback

后端 未结 4 818
滥情空心
滥情空心 2021-01-11 12:29

First off there seems to be no way to get an exact match using a full-text search. This seems to be a highly discussed issue when using the full-text search method and there

4条回答
  •  梦毁少年i
    2021-01-11 12:42

    This will give you the movies that contain the exact phrase "Toy Story", ordered by their popularity.

    SELECT
        m.[ID],
        m.[Popularity],
        k.[Rank]
    FROM [dbo].[Movies] m
    INNER JOIN CONTAINSTABLE([dbo].[Movies], [Title], N'"Toy Story"') as [k]
        ON m.[ID] = k.[Key]
    ORDER BY m.[Popularity]
    

    Note the above would also give you "The Goonies Return" if you searched "The Goonies".

提交回复
热议问题