Select additional information about matches

zequion 446 Reputation points
2024-09-24T21:52:12.5366667+00:00

When you perform a "Select Contains" searching for several words and their synonims and inflections, for each selected record Sql Server knows the number of word matches and knows which words have matched. It uses those values ​​to generate RANK.

How can I find out that information? Is there a structure that contains statistical information about each matched record?

Since I don't have that information, after performing a "Select Contains", in order to highlight the matches with a background color, I have to do a text search in each retrieved record searching for each of the words entered by the user + the synonyms of each word + the inflections of each word.

Consider that, perhaps, the program performs 1000 subsequent searches on each returned record and that slows down the display on the screen. Rodger Kong it reminded me that there is this link about the structure that contains the values ​​for each match. The problem is that I don't know how to retrieve that structure. https://learn.microsoft.com/en-us/sql/relational-databases/search/limit-search-results-with-rank?view=sql-server-ver16#statistics-for-ranking

SQL Server
SQL Server
A family of Microsoft relational database management and analysis systems for e-commerce, line-of-business, and data warehousing solutions.
13,865 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. LiHongMSFT-4306 27,101 Reputation points
    2024-09-25T01:57:59.92+00:00

    Hi @zequion

    Try using CONTAINSTABLE and FREETEXTTABLE, which return a relevance ranking value (RANK) and full-text key (KEY) for each row. For information about the forms of full-text searches that are supported by SQL Server, see Query with Full-Text Search.

    Best regards,

    Cosmog


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.