I am trying to compute ts_rank for full-text matching, where some of the terms in the request may not be in the ts_vector against which it is mapped. I would like the rank to be higher in the match, where there are more words. Seems pretty simple?
Since not all members must match, I must | operands to give a query, for example to_tsquery('one|two|three') (if it was & , everyone would have to match).
The problem is that the rank value seems to be the same no matter how many words match. In other words, it maximizes rather than multiplies sentences.
select ts_rank('one two three'::tsvector, to_tsquery('one')); gives 0.0607927 .
select ts_rank('one two three'::tsvector, to_tsquery('one|two|three|four')); gives the expected lower value of 0.0455945 , because four is not a vector.
But select ts_rank('one two three'::tsvector, to_tsquery('one|two'));
gives 0.0607927 and similarly
select ts_rank('one two three'::tsvector, to_tsquery('one|two|three'));
gives 0.0607927
I would like the ts_rank result ts_rank be higher if more matches worked.
Possible?
To answer one of the possible answers: I cannot calculate all possible subsequences of the search query as intersections, and then combine them all into a query, because I will work with large queries. I am sure that there are many arguments!
Edit: I know ts_rank_cd , but this does not solve the above problem.