How to solve an effective search for a string that may have several options?

My name sounds complicated, but the situation is very simple. People search on my site using a term like blackfriday.

When they do a search, my SQL code must search in different places, such as a field, ProductTitleand ProductDescriptionin order to find that term. For example:

SELECT * 
FROM dbo.Products 
WHERE ProductTitle LIKE '%blackfriday%' OR 
ProductDescription LIKE '%blackfriday%'

However, this term looks different in the database fields. It looks most like a space between words like "Black Friday USA 2015." So, without going over and adding more combinations to the sentence WHERE, such as WHERE ProductTitle LIKE '%Black-Friday%', is there a better way to do such a fuzzy search?

I have a full-text search in the above fields, but its really not so good when I use the sentence CONTAINS. And, of course, other terms may not be as neat as this example.

+4
source share
4 answers

, " ()" . , , / (, ), , : "blackfriday" "black friday" "black-friday". , 1 .

. , black-friday black friday, FREETEXT CONTAINS. blackfriday.

FREETEXT FREETEXTTABLE ( , ). , , , .

, , . :

  • , , . , black friday CONTAINS(*, '"black friday" OR "blackfriday"'). , , black friday treehouse ("black friday" OR "blackfriday") AND ("treehouse" OR "tree house")? , , "treehouse" .
  • ( , , , ), . do-re-mi "do re mi" OR "doremi" OR "do remi" OR "dore mi" OR "d oremi" OR "d o remi" .... , , , - , .
+1

/ .

  • , (, ProductTitle, ProductDescription)
  • , ( , , "%")
  • ( )
  • ( , ). , , , .
+1

Having studied everything, I decided to use full-text SQL search FREETEXT. This is not ideal or accurate, but at the moment it will need to be done.

+1
source

My answer is probably inadequate, but do you have any scripts that will not be discussed below.

SELECT * 
FROM dbo.Products 
WHERE ProductTitle LIKE '%black%friday%' OR 
ProductDescription LIKE '%black%friday%'
0
source

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


All Articles