我正在尝试执行以下简单查询:
SELECT "Documents", "Sentences"."sentence","Sentences"."VectorValue",
ts_rank("Sentences"."VectorValue", plainto_tsquery('Video provides a powerful way to help you prove your point. ')) as sim
FROM "Documents", "Sentences"
Where sim > 0.5
And "Documents"."Id" = "Sentences"."DID"
LIMIT 10;
但我一直得到这个错误:列“sim”不存在
我试过这个并且它工作但看起来效率不高,执行需要5秒钟:
SELECT ...., .... ,
ts_rank("Sentences"."VectorValue", plainto_tsquery('Video provides a powerful way to help you prove your point. '))
FROM "Documents", "Sentences"
Where ts_rank("Sentences"."VectorValue", plainto_tsquery('Video provides a powerful way to help you prove your point. ')) > 0.5
And "Documents"."Id" = "Sentences"."DID"
LIMIT 10;
通常,ts_rank会根据相关文档对特定查询的结果给出0-0.99的结果!
任何想法?
另外,这可以改进吗?
答案 0 :(得分:0)
尝试此查询:
select
exe.*
from
(
SELECT "Documents", "Sentences"."sentence","Sentences"."VectorValue",
ts_rank("Sentences"."VectorValue", plainto_tsquery('Video provides a powerful way to help you prove your point. ')) as sim
FROM "Documents", "Sentences"
And "Documents"."Id" = "Sentences"."DID"
) exe
where sim > 0.5
LIMIT 10;
答案 1 :(得分:0)
将您的ts_rank写为横向连接:
SELECT "Documents", "Sentences"."sentence","Sentences"."VectorValue"
FROM "Documents", "Sentences",
ts_rank("Sentences"."VectorValue", plainto_tsquery('Video provides a powerful way to help you prove your point. ')) as sim
Where sim > 0.5
And "Documents"."Id" = "Sentences"."DID"
LIMIT 10;