Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

When will Postgres's full text search supports phrase match and proximity match?

As of Postgres 8.4 the database fts does not support exact phrase match, nor does it support proximity match if given 2 terms. For example, there is no way to tell Postgres to match on content that have word #1 which is in a specified proximity of word #2. Any one know the plan of Postgres and possibly which version will phrase and proximity match be supported?

like image 797
hko19 Avatar asked May 25 '10 21:05

hko19


1 Answers

PostgreSQL 9.6 text search supports phrases now

select
  *
from (values
  ('i heart new york'),
  ('i hate york new')
) docs(body)
where
  to_tsvector(body) @@ phraseto_tsquery('new york')

(1 row retrieved)

or by distance between words:

-- a distance of exactly 2 "hops" between "quick" and "fox"
select
  *
from (values
  ('the quick brown fox'),
  ('quick brown cute fox')
) docs(body)
where
  to_tsvector(body) @@ to_tsquery('quick <2> fox') 

(1 row retrieved)
like image 141
Neil McGuigan Avatar answered Sep 21 '22 23:09

Neil McGuigan