When does Postgres full-text search support phrase matching and proximity?

As in Postgres 8.4, the fts database does not support exact phrase matching and does not support proximity if 2 conditions are specified. For example, there is no way to tell Postgres to match content containing the word # 1, which is in the given proximity from the word # 2. Does anyone know a Postgres plan and maybe which version will contain the phrase and proximity mapping?

+4
source share
2 answers

PostgreSQL 9.6 text search now supports phrases

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 the 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) 
+4
source

http://linuxgazette.net/164/sephton.html

<snip>

Search vectors

How to convert the contents of a document into an array of tokens using a parser and dictionaries? How does the search term relate to body text? PostgreSQL provides a number of functions for this. The first thing we'll look at is to_tsvector ().

Tsvector is an internal data type that contains an array of tokens with location information. Token positions are used in the search, to rank the search result based on proximity and other information. You can control the ranking by marking the various parts that make up the content for the search document, for example, the title, body, and abstract can be weighted differently during the search , marking these sections differently. Section signs, quite simply A, B, C and D, are associated with the tsvector at the time of its creation, but the weight modifiers associated with these labels can be controlled after the fact.

</snip>

For a full phrase search, see here.

Postgresql does not have a roadmap. Instead, you link to the "Open Issues" page . At the moment, this page does not mention a search in a full-sized phrase.

+2
source

All Articles