The PostgreSQL full-text search followed by operator requires one lexeme to occur a specified number of positions after another. Use it through to_tsquery when word order or distance matters, rather than merely requiring every term to appear. section 6.3.2
Match a three-position distance
SELECT id, name FROM omdb.movies WHERE lexemes @@ to_tsquery('return <3> king'); This query returns The Lord of the Rings: The Return of the King, matching “king” at the requested distance after “return.” The adjacent <-> form is also available for followed-by matching. section 6.3.2
