I’m using SQL Server FreeTextTable to do some relevance searching in a project. It works really nice for most standard searches, such as:
- sofa chair – to search for one/and or both
- “sofa chair” – to search for the phrase ‘sofa chair’
I’d like to add some boolean search capabilities, too, such as:
- sofa and chair – to search for both sofa as well as chair
- sofa -chair – to search for sofa but not chair
- “green sofa” or “red chair” to search for either ‘green sofa’ or ‘red chair’
Will I need to do a LIKE/NOT LIKE phrase in the search and then do a FreeTextTable for ranking? Is there some other way to do it?
I think LIKE/NOT LIKE is the easiest way to do it. Take the string you’re parsing for the search, like for “OR”‘s and “AND”‘s, and build your query dynamically. Similarly, if you encounter a ‘-‘ build a NOT statement. I don’t think it will be too difficult.
If you want to check out some of the advanced options available for SQL searches, I know MySQL supports regex strings, you can read all about it here:
http://dev.mysql.com/doc/refman/5.1/en/regexp.html