What's the difference between the ts_rank and ts_rank_cd?

From: hmidi slim <hmidi(dot)slim2(at)gmail(dot)com>
To: pgsql-docs(at)postgresql(dot)org
Subject: What's the difference between the ts_rank and ts_rank_cd?
Date: 2017-11-03 10:52:03
Message-ID: CAMsqVxvbMX4dBbEyGxVtu7+zwDnRf2g+9QdOWN3eL6r3WwRA-A@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-docs

Based on the official doc:
*'PostgreSQL provides two predefined ranking functions, which take into
account lexical, proximity, and structural information; that is, they
consider how often the query terms appear in the document, how close
together the terms are in the document, and how important is the part of
the document where they occur.'*

*The definition of ts_rank:*

*'Ranks vectors based on the frequency of their matching lexemes.'*

*Definition of ts_rank_cd:*

*'This function computes the cover density ranking for the given document
vector and query, as described in Clarke, Cormack, and Tudhope's "Relevance
Ranking for One to Three Term Queries" in the journal "Information
Processing and Management", 1999. Cover density is similar
to ts_rankranking except that the proximity of matching lexemes to each
other is taken into consideration.'*

Testing the ts_rank function with these examples:

*SELECT ts_rank( to_tsvector('name lastname name lastname'),
to_tsquery('name & lastname'));ts_rank: 0,3400053*

*SELECT ts_rank( to_tsvector('name lastname zzzzzzzz tttttt name
lastname'), to_tsquery('name & lastname'));ts_rank: 0,3344279*

*SELECT ts_rank( to_tsvector('name lastname xxxxx yyyyyyy zzzzzzzz tttttt
name lastname'), to_tsquery('name & lastname'));*

*ts_rank: 0,3187879why the function ts_rank gives different results however
I have the same number of searched items on the different examples? does
the distance was token into consideration into the ts_rank. If yes what's
is the difference between ts_rank and ts_rank_cd which is differ from the
first by the proximity of matching lexemes?*

Browse pgsql-docs by date

  From Date Subject
Next Message hmidi slim 2017-11-03 13:14:19 Explain the difference between ts_rank and ts_rank_cd
Previous Message Oleg Bartunov 2017-11-03 09:44:29 Re: Ts_rank_cd function