Skip to content

Ranks are above one #20

Closed
Closed
@poppingtonic

Description

@poppingtonic
postgres=# CREATE TRIGGER tsvectorupdate                                                                                                                                                         
postgres-# BEFORE UPDATE OR INSERT ON test_rum                                                                                                                                                   
postgres-# FOR EACH ROW EXECUTE PROCEDURE tsvector_update_trigger('a', 'pg_catalog.english', 't');                                                                                               
postgres=# INSERT INTO test_rum(t) VALUES ('The situation is most beautiful');                                                                                                                   
INSERT 0 1                                                                                                                                                                                       
postgres=# INSERT INTO test_rum(t) VALUES ('It is a beautiful');                                                                                                                                 
INSERT 0 1                                                                                                                                                                                       
postgres=# INSERT INTO test_rum(t) VALUES ('It looks like a beautiful place');                                                                                                                   
INSERT 0 1                                                                                                                                                                                       
postgres=# select * from test_rum ;                                                                                                                                                              
postgres=# select * from test_rum ;                                                                                                                                                              
                t                |                   a                                                                                                                                           
---------------------------------+----------------------------------------                                                                                                                       
 The situation is most beautiful | 'beauti':5 'situat':2                                                                                                                                         
 It is a beautiful               | 'beauti':4                                                                                                                                                    
 It looks like a beautiful place | 'beauti':5 'like':3 'look':2 'place':6                                                                                                                        
(3 rows)                                                                                                                                                                                         
postgres=# WITH tsq as (SELECT to_tsquery('english', 'place|beautiful') AS query) SELECT t, rank FROM (SELECT t, a <=> query AS rank FROM test_rum, tsq WHERE a @@ query = true) matches ORDER BY rank ASC LIMIT 10;
                t                |  rank   
---------------------------------+---------
 It looks like a beautiful place | 8.22467
 The situation is most beautiful | 16.4493
 It is a beautiful               | 16.4493
(3 rows)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions