Answer the question
In order to leave comments, you need to log in
How to make columns more weighty in PostreSQL when searching?
In Elasticsearch I can do like this
GET /_search
{
"query": {
"multi_match" : {
"query" : "this is a test",
"fields" : [ "subject^3", "message" ]
}
}
}
Answer the question
In order to leave comments, you need to log in
You, I hope, about FTS in PostgreSQL? Then, most likely, the answer is contained here https://www.postgresql.org/docs/9.5/static/textsea...
Creating an index
UPDATE table SET ftsindex =
setweight(to_tsvector(coalesce(subject,'')), 'A') ||
setweight(to_tsvector(coalesce(message,'')), 'D');
SELECT id, ts_rank_cd({1.0, 1.0, 1.0, 3.0}, ftsindex, query) AS rank
FROM table, to_tsquery('this is a test') query
WHERE query @@ ftsindex
ORDER BY rank DESC
LIMIT 10;
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question