Документ взят из кэша поисковой машины. Адрес оригинального документа : http://www.sai.msu.su/~megera/postgres/gist/tsearch/V2/docs/oscon_tsearch2/rank_cd.html
Дата изменения: Unknown
Дата индексирования: Sat Dec 22 10:27:39 2007
Кодировка:

Поисковые слова: m 45
Open Source Convention
 Previous   Next 

Function rank_cd

Returns a rank value using a cover density algorithm that penalizes search words that are far apart.

rank_cd([ k INT4, ] tsv TSVECTOR, tsq TSQUERY [, normalization INT4]) RETURNS FLOAT4

  • 'k' is an integer that sets how far apart search words can be before they are penalized for not being close. The default value is 4.
  • 'tsv' is a text search vector to match against the text search query 'tsq'.
  • 'normalization' is an integer that sets how the rank value is scaled by the length of the text search vector.
    • The default value '0' does not adjust the rank value.
    • A value of 1 divides the rank by the logarithm of the length of 'tsv'.
    • A value of 2 divides the rank by the length of 'tsv'.
SELECT set_curcfg('default_english');
 
 set_curcfg
------------

(1 row)


SELECT file, title, rank_cd(ts_vec, to_tsquery('create & schema')) 
FROM postgresql_manual 
WHERE ts_vec @@ to_tsquery('create & schema') 
ORDER BY rank_cd(ts_vec, to_tsquery('create & schema')) DESC 
LIMMIT 5;
          
	  file           |      title      | rank_cd
-------------------------+-----------------+---------
 sql-createschema.html   | CREATE SCHEMA   | 44.5817
 ddl-schemas.html        | Schemas         | 30.2858
 bookindex.html          | Index           | 12.1279
 sql-createsequence.html | CREATE SEQUENCE | 6.92208
 sql-grant.html          | GRANT           | 6.56535
(5 rows)

SELECT file, title, rank_cd(1, ts_vec, to_tsquery('create & schema')) 
FROM postgresql_manual 
WHERE ts_vec @@ to_tsquery('create & schema') 
ORDER BY rank_cd(1, ts_vec, to_tsquery('create & schema')) DESC 
LIMIT 5;
          
	  file           |      title      | rank_cd
-------------------------+-----------------+---------
 sql-createschema.html   | CREATE SCHEMA   | 16.3121
 ddl-schemas.html        | Schemas         | 9.40478
 bookindex.html          | Index           | 4.53197
 sql-createsequence.html | CREATE SEQUENCE | 2.06385
 sql-createtable.html    | CREATE TABLE    | 1.82864
(5 rows)