I'm performing weighted search on a series of items in an e-commerce platform. The problem I have is ts_rank is giving me the exact same value for different combinations of words, even if the ts_vector gives different positions for each set of words.
Let me illustrate this with an example:
If I give ts_vector the word camas
, it gives me the following:
'cam':1
If I give ts_vector the word sofas camas
, it gives me the following:
'cam':2 'sof':1
So camas
is getting different positions depending on the words combination.
When I execute the following statement:
select ts_rank(to_tsvector('camas'),to_tsquery('spanish','cama'));
PostgreSQL gives me 0.0607927
as the ts_rank computed value, whereas the computed value for the following statement:
select ts_rank(to_tsvector('sofas camas'),to_tsquery('spanish','cama'));
is the same value: 0.0607927
.
How can this be?
The question I have in mind is the following: is there a way for ts_rank to consider the position for the words contained in the ts_vector structure as-is or is there a way to define a custom ts_rank function for me to take the position for the words as explained?
Any help would be greatly appreciated.