May 1, 2006 at 12:25 pm
If I have a column Notes varchar(100) which has values "Sacramento First Office"
I can search for that row with value of "men" by stating where notes like '%men%'
How can I get the same result by using Contains of Free text query.
Amit Lohia
May 2, 2006 at 1:25 am
Amit,
I'm assumung you've already created a full text catelogue for this table?
If you have you just need to run a query like this one:
SELECT ColumnName
FROM ColumnName
WHERE CONTAINS(FulltextCatelogueName, 'men')
Hope this helps
Ed
May 2, 2006 at 10:52 am
Nope it does not work as men in part of the word and not the whole word or the start of the word
Amit Lohia
May 2, 2006 at 10:56 am
No problem,
Try putting a wild card in so it becomes:
SELECT ColumnName
FROM ColumnName
WHERE CONTAINS(FulltextCatelogueName, '%men%')
Hope that helps.
Ed
May 2, 2006 at 10:57 am
Already done and no help
The actual wild character is "*" and not "%" and even the search should be part of double quote (")
FROM ColumnName
WHERE CONTAINS(FulltextCatelogueName, '"men*"')
Amit Lohia
May 2, 2006 at 11:01 am
Sorry, just trying to help, i have it all coded somewhere but was working from memory to give you pointers. I would have looked it up for you if you had come back with problems.
May 2, 2006 at 11:05 am
Thank you EIJ for taking the time and atleast responseding. It is better to post any solution which you can think as many time we forget the most basic answer. Once again thank you.
Amit Lohia
May 2, 2006 at 12:30 pm
Hi, Amit,
I have been wondering about the same issue with a table that has over 10 million rows. A Full-Text Index was built to facilitate free text search on one varchar(50) column. How surprised was I to find out that the CONTAINS query did not return anything if the search text was not a whole word or at the beginning of a word. It seems that LIKE '%Text%' is the only way to go. But it is so horribly slow. Did you get any solution?
Larry
May 2, 2006 at 3:35 pm
Well I still do not have an answer infact, now this scenario is working as an advantage for us
Amit Lohia
May 3, 2006 at 12:09 am
LXZ20 and Amit,
Are you saying this doesn't work?
FROM ColumnName
WHERE CONTAINS(FulltextCatelogueName, '"*men*"')
This is my code exactly I've just taken from a project which is verified to work:
SELECT DISTINCT Res.RANK AS RANK, ArticleID
FROM ARTICLESFT INNER JOIN
CONTAINSTABLE(ArticlesFT, *, '''*Men*''' )
Res ON ARTICLESFT.ID = Res.
Order by RANK DESC
Making it a little more generic it becomes:
SELECT DISTINCT Res.RANK AS RANK, COLUMNNAME
FROM TABLENAME INNER JOIN
CONTAINSTABLE(COLUMNNAME, *, '''*Men*''' )
Res ON TABLENAME.ID = Res.
Order by RANK DESC
I hope this helps, I just tried it and it returned results on my system, just note, there are no double quotes, just three single quotes before and after the search word.
May 3, 2006 at 7:32 am
EIJ,
No, the following syntax didn't work:
FROM ColumnName
WHERE CONTAINS(FulltextCatelogueName, '"*men*"')
I tried the following, and it didn't return expected result, either.
FROM TableName
WHERE CONTAINS(ColumnName, '"*men*"')
Thanks.
Larry
May 3, 2006 at 7:39 am
What does it bring back?
A syntax error or just no results?
Viewing 12 posts - 1 through 11 (of 11 total)
You must be logged in to reply to this topic. Login to reply