Sample Header Ad - 728x90

How to search for partial matches from a GIN index in a multi-word PostgreSQL query?

1 vote
1 answer
331 views
I have a GIN index in a Postgres database that I'm currently using to do full text search. So if a tsvector field contains the vectorized form of "mary had 4 little lambs" then I could search for "4 little lambs" with: SELECT * FROM mytable WHERE text_index @@ to_tsquery('pg_catalog.english', '''4 little lambs'':*'); However, if I try to search for "4 lambs" with: SELECT * FROM mytable WHERE text_index @@ to_tsquery('pg_catalog.english', '''4 lambs'':*'); this query returns no results. Why isn't the index finding any partial matches? What's wrong with my syntax?
Asked by Cerin (1425 rep)
Dec 6, 2022, 01:43 AM
Last activity: Dec 6, 2022, 02:36 AM