Best way to search in varchar column on sql server

What do you recommend looking in the sql server table (varchar (max) column) for the term?

Say like on ebay, if you search for “wii brand new”, you get results like “Brand New Nintendo Wii Fit Game + Balance Board Bundle”, “Wii Fit (Wii) BRAND NEW WII FIT GAME + BALANCE BOARD” .

I think that it basically searches for every word and returns those that contain all the words, what would you recommend?

+4
source share
2 answers

You are looking for full-text indexing, this allows you to perform more complex queries than regular expressions or how.

Check out this article for quick reference, instructions for SQL Server 2000, where it’s a little harder to set up than in 2005 or 2008.

Relevant quote:

  With full-text searching, you can perform many other types of search:

  * Two words near each other
  * Any word derived from a particular root (for example run, ran, or running)
  * Multiple words with distinct weightings
  * A word or phrase close to the search word or phrase
+3
source

Depends on what you are trying to do. For a simple search, you can simply do select * from table where field like '%word%' . But if this is some feature of the application, you want to look into the full-text search application. It can store words that appear in this field as indices, and then search for those words instead of using this field.

+1
source

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


All Articles