I have a database of instagram posts which needs to be searchable. Current implementation uses TSVECTOR column and @@ operator to search against it:
CREATE TABLE ig_posts (
/* ... */
caption_tsv TSVECTOR
);
Posts insert SQL:
INSERT INTO ig_posts(caption_tsv)
VALUES (to_tsvector('simple', ?)) /* simple, because post can be in any language */
Search SQL:
SELECT *
FROM ig_posts
WHERE ig_posts.caption_tsv @@ to_tsquery('simple', ?)
Everything works great, except some posts might contain utf8 encoded bold/italic text, for example:
'rosegold':26 'sunshine':23 '':1 '':4 '':2 '':3 '':21 '':17 '':15
This causes the @@ operator to fail, since the "Always" and "" are considered different words. Is it possible to covert bold/italic UTF8 text back to normal within Postgres?
Edit: the accepted answer works perfectly, here is the rules file that I used: https://gist.github.com/dsenkus/9250134b338b9862585963dfdf450e13
And the script that was used to generate it: https://gist.github.com/dsenkus/17ddbd29d53bd6dd2cf4051bd05ad44d (generated results requires some cleanup, since some special letters do not exist in UTF8, and 3rd h letter is not recognized, ℎ should be used as value)