PSQL: Full text search to ignore or match periods and stop characters

Viewed 374

I have a full-text search running fine using tsvector / tsquery:

to_tsvector('simple', text) @@ plainto_tsquery('simple', :query)

I am formatting the query to include partial matches:

{ query: `${searchTerm}:*` }

However, if I search for 'node' it does not match against text that contains 'node.js'.

How can I include partial matches that have a period or other similar stop character?

1 Answers

Appending :* to the search term and then passing it to plainto_tsquery doesn't make any sense, as plainto_tsquery just strips the :* back off again. You would need to either use to_tsquery, or just write the query directly. For example,

select to_tsvector('simple', 'node.js') @@ 'node:*'::tsquery;

yields true.

Related