Skip to content

Instantly share code, notes, and snippets.

@ultrasaurus
Created May 4, 2010 00:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ultrasaurus/388812 to your computer and use it in GitHub Desktop.
Save ultrasaurus/388812 to your computer and use it in GitHub Desktop.
PGError: ERROR: function ts_rank_cd(text, tsquery) does not exist
LINE 1: SELECT phrases.*, ts_rank_cd(phrases.vectors,tsearch_query) ...
@ultrasaurus
Copy link
Author

SHOW search_path;

search_path

"$user",public
(1 row)

@wayneeseguin
Copy link

wallboard_development=# \df ts_rank_cd
                                    List of functions
   Schema   |    Name    | Result data type |        Argument data types         |  Type  
------------+------------+------------------+------------------------------------+--------
 pg_catalog | ts_rank_cd | real             | real[], tsvector, tsquery          | normal
 pg_catalog | ts_rank_cd | real             | real[], tsvector, tsquery, integer | normal
 pg_catalog | ts_rank_cd | real             | tsvector, tsquery                  | normal
 pg_catalog | ts_rank_cd | real             | tsvector, tsquery, integer         | normal
(4 rows)

Look carefully at the signatures.
You're original error shows that 'phrases.vectors' is a 'text' object, not a tsvector object as expected.
Likely you'll need to do a to_tsvector()

wallboard_development=# \df to_tsvector
                             List of functions
   Schema   |    Name     | Result data type | Argument data types |  Type  
------------+-------------+------------------+---------------------+--------
 pg_catalog | to_tsvector | tsvector         | regconfig, text     | normal
 pg_catalog | to_tsvector | tsvector         | text                | normal
(2 rows)

Essentially what I'm saying is change the query to:

SELECT phrases.*, ts_rank_cd(to_tsvector(phrases.vectors), tsearch_query) ...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment