views:

33

answers:

1

Hi,

I would like to know how to exclude apostrophes from being indexed in full text search.

For example, if someone enters a search term for "o'brien" or for "obrien" I would want it to match all cases where someone's name matches either "O'Brien" or "OBrien".

However, if I search on:

select * from MyTable where contains (fullName, '"o''Brien*"')

It returns only ones with an apostrophe. But if I do:

select * from MyTable where contains (fullName, '"oBrien*"')

It only returns the ones without an apostrophe.

In short, I want to know if it is possible for FTS to index both "O'Brien" and "OBrien" as "obrien" so that I can find both.

While the solution:

select * from MyTable where contains (fullName, '"oBrien*" OR "o''Brien*"')

would work, however, I can't make that assumption if the user entered "obrien".

I'm looking for a solution that works both on SQL Server 2005 and 2008.

A: 

depending on how much space you have, you could add another column

fullName_noPunctuation

containing only the alpha characters of the name, strip punctuation from your search criteria, and search the punctuation-free column instead.

Beth
This may work for me. I'll have to look into it. However, it would be nicer if there was a way to get it to just index "O'Brien" and "OBrien" as "obrien".
Avrom
Added a new column with the "fullName" stripped of its apostrophes and created a FTS index on it. It was able to find both the O'Briens and the Obriens using a contains (fullSearch, '"obrien*"').
Avrom