In PostgreSQL is there a way to rank/weigh columns so as to order the results? Let's say I am searching through three text columns. I don't just want results that match a given word or phrase, but I also want to weigh them (column A &gt; column B &gt; column C) - thereby ordering the results such that those rows matching the word in column A will come up higher than those matching in column B, and those matching in column B will come up higher than those matching in column C.

Is this possible? Can you provide me with some terminology or suggestions for further reading?
Full text search has detailed weighting mechanisms.

For simple pattern matching:

SELECT *
FROM   t
WHERE  col_a ILIKE '%keyword%' OR
       col_b ILIKE '%keyword%' OR
       col_c ILIKE '%keyword%' 
ORDER  BY col_a ILIKE '%keyword%' OR NULL
        , col_b ILIKE '%keyword%' OR NULL
        , col_c ILIKE '%keyword%' OR NULL;


I don't use col_a  ILIKE '%keyword%' DESC, because that would sort NULL columns first. We want to treat NULL just like FALSE, which is achieved this way.