Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 Full-Text Search

Author  Topic 

Eran
Starting Member

6 Posts

Posted - 2012-11-18 : 07:05:18
Hi,

I am quering a big table (about 150,000 rows) with a big varchar field (size 2000) which can't be indexed (and there's no point even if it could be). I am using Sql Server 2008.
The query I used till now was:

select *
from tbl_name
where field_name like '%bla bla%'

("bla bla" is according to what the user searched for)

In order to improve performence, I wann'a start using the Full-Text Search feature (already defined a catalog and a text index on this field).
I am a bit confused from what I read about quering with this option.
what query should I use in order to get exactly the same results as the query I used to use before?

* Comments:
1. I would like to get results which are not case sensative, as it worked before (meaning if the user searches for "LG" he will also get results that contains "Lg").
2. If user enters "Sams" he will also get "Samsung".

Thanks!
Eran.

Eran
Starting Member

6 Posts

Posted - 2012-11-19 : 04:21:58
I want to query by the whole string that the user has entered, as one phrase.

The CONTAINS query doesn't returns the results I need even with one word.

Lets say I have 5 rows in the DB:

1. ggg Eran fff
2. hhhEranttt
3. Eranggg
4. hhhhh Eran
5. rrrggg Eran fffhhh

and I query by:

SELECT *
FROM tbl_name
WHERE CONTAINS(field_name, '"eran"');


I only get rows 1,4,5 as the results, but I need to get them all.

So, there is no way to use the free text index instead of quering by

WHERE field_name LIKE '%[search_text]%' ?

Go to Top of Page
   

- Advertisement -