- Notifications
You must be signed in to change notification settings - Fork59
Closed
Description
Hello, thank you for this great extension!
I think I've spotted some problem. When searching
- ... with a phrase-query like
foo <-> bar - ... using an index of the
rum_tsvector_addon_opsoperator class - ... it doesn't find anything.
Let's setup a test table with text valuesa a,a b,a c and so on.
create extension rum;createtabletext_table (id1serial, ttext);createtablerum_tbl (idserial, tsv tsvector);insert into text_table(t)select chr(i)||''|| chr(j)from generate_series(65,90) i, generate_series(65,90) j;insert into rum_tbl(tsv)select to_tsvector('simple', t)from text_table;
Without any index we can query ona <-> b, which works like expected:
select*from rum_tblwhere tsv @@ to_tsquery('simple','a <-> b');
id | tsv ----+------------- 2 | 'a':1 'b':2(1 row)Now let's create an index using therum_tsvector_addon_ops operator class:
createindexrum_tbl_idx_addonon rum_tbl using rum (tsv rum_tsvector_addon_ops, id) with (attach='id', to='tsv');
The same query now fails to return the matching row:
select*from rum_tblwhere tsv @@ to_tsquery('simple','a <-> b');
id | tsv ----+-----(0 rows)Explain analyze says:
Bitmap Heap Scan on rum_tbl (cost=3.33..6.45 rows=4 width=28) (actual time=0.097..0.097 rows=0 loops=1) Recheck Cond: (tsv @@ '''a'' <-> ''b'''::tsquery) -> Bitmap Index Scan on rum_tbl_idx_addon (cost=0.00..3.33 rows=4 width=0) (actual time=0.093..0.093 rows=0 loops=1) Index Cond: (tsv @@ '''a'' <-> ''b'''::tsquery)A query using anAND operator works correctly:
select*from rum_tblwhere tsv @@ to_tsquery('simple','a & b');-- ... result has 2 rows
Interestingly, the phrase-query also works correctly if we only have arum_tsvector_ops index:
dropindex rum_tbl_idx_addon;createindexrum_tbl_idxon rum_tbl using rum (tsv rum_tsvector_ops);select*from rum_tblwhere tsv @@ to_tsquery('simple','a <-> b');-- ... result has 1 row
Tested with PostgreSQL 11.5 and RUM 1.3.7.
Any help greatly appreciated. Thank you in advance!
Metadata
Metadata
Assignees
Labels
No labels