Crezzer7
Crezzer7

Reputation: 2335

How do I do a full-text keyword search

not 100% sure on how to title this, but here's my question

say I want to find multiple words in a string, for example: "AHU Replacement"

now the user could have stored this in the database as

"Replacement of AHU"
"Replacement of the AHU"
"The AHU needs Replacing"

and most likely in many more ways, so how could I write a query that could scan through a table and detect all of these based on this search string as an example "AHU Replacement" which would be stored in a table itself as key searches

this code could find the 1st two strings above, however the variation of "Replacing" and "Replacement" is an issue:

SELECT * FROM ProjectNotes where Notes like '%AHU%' and Notes like '%replacement%'

Upvotes: 1

Views: 127

Answers (1)

leeor
leeor

Reputation: 17811

From what I understand of your question, what you are looking for is full text search capability. Full text search uses special kinds of indices in order to do powerful things like computing the relevancy of matches. You can do some pretty powerful string matching with it that just isn't possible any other way. Sql server supports this. For sql server 2012, take a look at this post for details on how to enable it.

Also see this helpful video for some more information on simple usage.

Upvotes: 4

Related Questions