Hi all,
In a pretty typical scenario, I have a 'Search' text box on my web application which has user input passed directly to a stored procedure which then uses full text indexing to search on two fields in two tables, which are joined using appropriate keys.
I am using the CONTAINS predicate to search the fields. Before passing the search string in, I do the following:
SET @ftQuery = '"' + REPLACE(@query,' ', '*" OR "') + '*"'
Changing the castle to "the*" OR "castle*", for example. This is necessary because I want people to be able to search on cas and get results for castle.
WHERE CONTAINS(Building.Name, @ftQuery) OR CONTAINS(Road.Name, @ftQuery)
The problem is that now that I have appended a wildcard to the end of each word, noise words (e.g. the) also have a wildcard appended and therefore no longer appear to get dropped. This means that a search for the castle will return items with words such as theatre etc.
Changing OR to AND was my first thought, but that appears to simply return no matches if a noise word is then used in the query.
All I am trying to achieve is to allow the user to enter multiple, space separated words that respresent either the entirety or a prefix of the words they are searching on, in any order - and drop noise words such as the from their input (otherwise when they search for the castle they get a big list of items with the result they need somewhere in the middle of the list.
I could go ahead and implement my own noise word removal procedure, but it seems like something that full text indexing ought to be able to handle.
Grateful for any help!
Jamie