Apostrophes and SQL Server FT Search

I have a FT search setup in SQL Server 2005, but I canโ€™t find a way to match the keyword โ€œLiasโ€ to the record with โ€œLia'sโ€. I basically want people to be able to search without an apostrophe.

I have been discussing this issue for a long time, so any help will truly be a blessing.

+2
source share
3 answers

EDIT 2: just realized that this does not actually solve your problem, please ignore and see another answer! The code below will return the results for the case when the user inserted an apostrophe, which should not be, for example, "left his load."

FT, - CONTAINS , , ..

SELECT *
FROM table
WHERE CONTAINS ('value' OR Replace('value', '''',''))

EDIT: , ,

SELECT *
FROM table
WHERE CONTAINS ("this phrase" OR Replace("this phrase", '''',''))

. MSDN CONTAINS. , , ; CONTAINS('value') .

+1

FT, varchar , O'Reilly, :

surname like Replace( @search, '''', '') + '%' or
Replace( surname,'''','') like @search + '%' 

, . , , .

(, , ) 2- , -- (?) . , Lia Lias. ..

0

Another attempt:

SELECT surname
FROM table
WHERE surname LIKE '%value%'
OR REPLACE(surname,'''','') LIKE '%value%'

This works for me (without FT enabled), that is, I get the same results when searching for O'Connor or OConnor.

0
source

Source: https://habr.com/ru/post/1761991/


All Articles