I’ve been tasked with creating a “google-esque” search mechanic on a new application, and I’ve hit a bit of a wall with the stored procedure that is intended to run the actual search in the SQL server database.
Essentially, the procedure is being passed in a string taken from a user input, which is then parsed into a contains statement using the following replace.
SELECT @SearchString = '"'+ REPLACE(REPLACE(@SearchKeyword,'"',''), ' ', '" AND "') +'"'
This works great unless the @SearchKeyword variable contains a stop-word, at which point, the inclusion of this as part of a chained AND statement result in a bug where no results are found.
(e.g. Searching for a user using “Something Somewhere” returns the correct result set, but Something of Somewhere would return nothing due to of not being contained in the full text index catalog).
I know I could take the nuke-from-orbit approach of removing all entries from the stop list, but ideally I want to simply modify the original replace to not chain into the and statement words contained in the stop list.
Unfortunately, this takes me to the ragged edge of my knowledge, and I can not find where I would pull this information in from in order to make use of it for the purpose of the replace.
Am I on the right track, or would the removal of the stop list (while messy) serve as the best solution?
Found the answer to this, and so will leave it here for reference.
You can identify which words from the input are default stop words by passing the text into the sys.dm_fts_parser