Right now I have a query that looks something like this
SELECT id
FROM products
WHERE products.details->'make' = ?
OR products.details->'model' = ?
OR products.details->'year' = ?
I'd like to sort the results by how many of the where statements matched, so for example if the three terms that were used in the query were ford, f150, 1985, and I got two results. One that had all three terms in it (a ford f150 from 1985), and a second result that had only two matches (a ford f150 from 1991).
Is there a way for me to do this with postgreSQL 9.3, or will I need to use my application layer to figure out how many matches there were?