进行全文研究并限制按等级编号返回的记录

时间:2019-03-26 08:51:13

标签: sql postgresql alias postgresql-10

在Postgresql 10中,我正在进行全文搜索,并且当rank低于预定义数字时,我不想接收记录。

 SELECT i.id, i.slug, i.name, i.short_description,
    ts_rank(
        setweight(to_tsvector(COALESCE(i.name, '')), 'A') || 
        setweight(to_tsvector(COALESCE(i.short_description, '')), 'B') || 
        setweight(to_tsvector(COALESCE(i.description, '')), 'B') || 
        setweight(to_tsvector(COALESCE(o.name, '')), 'C') || 
        setweight(to_tsvector(COALESCE(o.short_description, '')), 'D'),
    plainto_tsquery('balenare')) AS rank 
    FROM items_item AS i INNER JOIN owners_owner AS o 
    ON i.owner_id = o.id 
    WHERE i.is_active = true AND rank > 10000
    ORDER BY rank DESC

出现错误,因为我添加了条件rank > 10000

  

错误:列“ rank”不存在

是真的,但我仍然想将排名作为限制

0 个答案:

没有答案