this is not wanted behavior either, for the purpose of my application i also need this to return 1
select
ts_rank(
setweight(
to_tsvector('bed'),
'A'
),
to_tsquery('bed')
);
how is this behavior explained? how can i get a perfect 1 with ts_rank? i can't wrap my head around this
ts_rank
----------
0.607927
select
ts_rank(
setweight(
to_tsvector('bed sofa'),
'A'
),
to_tsquery('bed & sofa')
);
ts_rank
----------
0.991032
Im running the next query on my postgresql (9.6) select ts_rank( setweight( to_tsvector('bed'), 'A' ), to_tsquery('bed') ); i was expecting ...
select
ts_rank(
setweight(
to_tsvector('bed sofa table'),
'A'
),
to_tsquery('bed & sofa & table')
);
You'd have to read the source for details, but experiments show that the rank exceeds 0.6 as soon as a single word matches.
ts_rank
----------
0.999999
So you could simply create a function that adjusts the rank the way you want:
select
ts_rank(
setweight(
to_tsvector('bed sofa table sky'),
'A'
),
to_tsquery('bed | sofa | table'),
0
);
我在我的postgresql(9.6)上运行下一个查询。
ts_rank
----------
0.607927
我希望得到1(单词是相同的),但我得到的是
做一个不同的查询。
结果竟然是这样的但我不想要这个,我希望得到一个1,当单词相同,除了他们的数量。
另一个测试,这次有