Today I Learned

A Hashrocket project

Ready to join Hashrocket? Find Openings here and apply today.

Wildcard prefix matching with tsquery

When performing full-text search in Postgres you can add :* to the end of a string to be searched:

select title from posts where title::tsvector @@ 'instr:*'::tsquery;

This will match any post that has a word in its title that starts with instr

Looking for help? Hashrocket developers believe that data quality is as important as code quality. We enjoy all the challenges of relational databases, from finding the fastest index, to structuring data to fit the needs of an application. We're eager to share our experiences; check out PG Casts, our series of free PostgreSQL screencasts.