Now first and foremost, this is FTS. All words in the search string get tokenized as a ts_query
. From that point on the original search string is lost. So you don'tYou no longer have the actual word any more,words you have a tokenlexemes -- tokens which hashave been stemmed and normalized.
Getting your array to a ts_query
,
Essentially, a ts_query
looks like, 'fox' & 'jump' & 'dog' & 'foo' & 'bar'
In 9.6
9.6+ makes this very easy, you just have to do array_to_tsvector(array)
Pre 9.6
You should review plainto_tsquery
which does slightly more voodoo to get text
to a tsquery
, and to_tsquery
which assumes the string is already properly formatted.
To get the array to a ts_query
, you can do something like this
Essentially, a ts_query
looks like, 'fox' & 'jump' & 'dog' & 'foo' & 'bar'
You should review plainto_tsquery
which does slightly more voodoo to get text
to a tsquery, and to_tsquery
which assumes the string is already properly formatted.
Highlighting
Getting out the "words"