Click here to Skip to main content
15,914,357 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,
I have used SQL FREETEXTTABLE to search in a table column based on the user entered words like a search engine and return best matching rows.
Table column will contain many questions and user will type something in textbox (in any order) and based on what he has typed I need to auto populate the search page.
I have used FREETEXTTABLE for it. But its not working in some cases.

What I have tried:

If I type 'what' it does not return anything.
SQL
DECLARE @query VARCHAR(50) = 'what'
SELECT TOP 10 Questions
FROM tblQuestion tq INNER JOIN FREETEXTTABLE(tblQuestion, Questions, @query) ft 
ON ( tq.ID = ft.[Key] )
ORDER BY ft.Rank DESC

but if I type 'what is' it returns the 10 records.
SQL
DECLARE @query VARCHAR(50) = 'what is'
SELECT TOP 10 Questions
FROM tblQuestion tq INNER JOIN FREETEXTTABLE(tblQuestion, Questions, @query) ft 
ON ( tq.ID = ft.[Key] )
ORDER BY ft.Rank DESC

I also tried CONTAINS and FREETEXT.
SQL
SELECT * FROM tblQuestion WHERE FREETEXT (Questions,'what')

Even this query returned zero rows.
But this below query returned few rows.
SQL
SELECT * FROM tblQuestion  WHERE FREETEXT (Questions,'what is')


I want it to return even if there is single word typed by user.
Anyone knows the solution please help.

Thanks.
Posted
Updated 7-Sep-16 18:38pm
v2

1 solution

Hi ,

In sql server have a Some stoplist of words there.

Here is the query to check for list of stop lists

SQL
SELECT ssw.stopword, slg.name
      FROM sys.fulltext_system_stopwords ssw
      JOIN sys.fulltext_languages slg
      ON slg.lcid = ssw.language_id
      WHERE slg.lcid =1033


Here is the link for more detail
stop words list .

Becoz of the stoplist you are getting any rows.

Thanks
:)
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900