9

what is the query to use to search for text that matches the like operator.

I am asking about full text search query, which is of the form

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

I want results with "message" as well but right not it does not return anything

2 Answers 2

23

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

SELECT * 
FROM eventlogging 
WHERE description_tsv @@ to_tsquery('mess:*');
Sign up to request clarification or add additional context in comments.

1 Comment

is there anything for suffix matching as well
-7

You can use LIKE for exact case matches or ILIKE for case insensitive. Use the % as your wildcard.

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'

1 Comment

I am asking about full text search query, which is of the form SELECT * FROM events WHERE description_tsv @@ plainto_tsquery('mess*'); I want results with message as well but right not it does not return anything

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.