views:

57

answers:

2

Hi

I have a table (lets say it has one column called 'colLanguage') that contains a list of skills and has a full text index defined on it. One of the entries in the table is 'c#' but when I search for 'c#' (using the following SQL) I get no results back.

select * from FREETEXTTABLE(tblList, colLanguage, 'c#')

Can anyone help?

Thanks K

+1  A: 

As far as I understand it, # is registered as a "word breaker" and so is not added to the index. You might be able to deregister it from the list of word breakers as described on this page:

http://msdn.microsoft.com/en-us/library/dd207002.aspx

ho1
I need to look into this answer to see if I can do this before I mark it as the answer
Keith K
Using the following will enable you find the word breaker for your language but not enable you to edit the list of work breaking characters. It seems you have to write your own word breaker or ditch FTS if you want to do this.SELECT * FROM sys.fulltext_languages;EXEC sp_help_fulltext_system_components 'wordbreaker';
Keith K
A: 

My final solution is based on the fact that 'C#' is treated differently to 'c#'. When the letter before the '#' character is upper case the '#' is NOT treated as a word breaking character. Therefore I had to write a script update the table the full-text index was on to change all 'c#' into 'C#' (I then run this script as a sql job to ensure there isn't any lover case c#) and ensure when searching that 'c#' is changed into 'C#' which I did in my code.

Alternately if you have SQL2008 and can change the full-text language for the fts index you can set it to use the 'Neutral' language as the word breaker for the indexed columns. The 'Neutral' word breaker only breaks on white text. Then change your fts command to specify the that as the language used e.g. select * from FREETEXTTABLE(tblList, colLanguage, 'c#', LANGUAGE 0) you can seach for 'c#' or 'C#' with no other changes required* apart from rebuilding you indexes.

*you might need to change the 'default full-text Language' for your database instance, I had to.

Keith K