Postgres full-text search as operator

which query is used to search for text that matches the type operator.

I am asking about a full-text search query that looks like

SELECT * FROM eventlogging WHERE description_tsv @@ plainto_tsquery('mess'); 

I want the results to also be with a β€œmessage”, but return nothing

+4
source share
2 answers

If I read the description in the manual correctly, you will need to use to_tsquery() instead of plainto_tsquery along with a wildcard to allow prefix matching:

  SELECT * 
 FROM eventlogging 
 WHERE description_tsv @@ to_tsquery ('mess: *');
+9
source

You can use LIKE to match the exact case, or ILIKE for case insensitivity. Use % as a template.

This will match anything with "SomeThing" in it (case sensitive).

 SELECT * FROM table WHERE name LIKE '%SomeThing%' 

This will match anything ending with "ing" (case insensitive).

 SELECT * FROM table WHERE name ILIKE '%ing' 
-3
source

Source: https://habr.com/ru/post/1334127/


All Articles