How to search for phrases?

0127

To search for phrases in PostgreSQL using full-text search, you can use the phraseto_tsquery function. This function allows you to search for exact phrases rather than individual words. Here's how you can do it:

SELECT title, content 
FROM articles 
WHERE search_vector @@ phraseto_tsquery('english', 'your phrase here');

In this example, replace 'your phrase here' with the exact phrase you want to search for. The query will return articles that contain that specific phrase in the search_vector.

Keep in mind that the phrase must match exactly, including the order of the words.

0 Comments

no data
Be the first to share your comment!