0

Given an arbitrary full text search (FTS) query, it's required to list keywords from the resulting document which match the query. For example, test or rest produces list of 3 documents where 1st one contains only test, 2nd one contains both of the words and the 3rd one has only rest. The explanation should produce 3 lists: (test) (test, rest) (rest) for the end user to understand why the documents appeared in the query output.

The question is related to hit-highlighting and I've explored existing solutions (e.g. http://www.codeproject.com/Articles/623815/Hit-Highlight-for-SQL-Server-Full-Text-Search or How to do hit-highlighting of results from a SQL Server full-text query). Those solutions rely on sys.dm_fts_parser fed with hard-coded FORMSOF (INFLECTIONAL to produce all permutations of the search term.

Particularly, solutions relying on sys.dm_fts_parser seem to stumble upon a prefix search. For example, given 2 queries test and "test*" select content from table where contains(content, @query, language 1033) produces different result sets, but select * from sys.dm_fts_parser(@query, 1033, 0, 1) yields 2 absolutely identical recordsets, which doesn't give any clue as to why query outputs are different.

Anyone has any experience with similar cases?

Community
  • 1
  • 1
Sergey Tarasov
  • 858
  • 11
  • 18
  • Have you tried [ThinkHighlight](http://www.interactivethoughts.com/products/thinkhighlight/)? – superware Apr 07 '15 at 17:12
  • I know about the library, though I haven't actually tried it. In my case it was ruled out because it requires to upload an unsafe assembly into SQL server, which is not allowed in my production environment. – Sergey Tarasov Apr 08 '15 at 07:30
  • Sometimes you can't recreate internal SQL Server functionality without "getting in". By the way, "unsafe" absolutely doesn't mean the assembly is unsafe for use, it's only a code permission. – superware Apr 09 '15 at 07:55

0 Answers0