postgrespro/rum

In a query, `||` does not work when nested in `<->`

1Computer1 opened this issue · 4 comments

The query (A || B) <-> C does not give any results, though it should be equivalent to (A <-> C) || (B <-> C), which does.
The built in GIN index can handle this case.
There may be other problems with ||, though I haven't looked too deep into it.

I'm using a rum_tsvector_addon_ops index attaching a float.

Thanks!

Apologies, I couldn't reproduce it with a small set of data so this will be large file:
data.zip

Set up:

create extension rum;

create table documents (
    en text not null,
    score float not null
);

alter table documents
    add column textsearch_index_en_col tsvector
        generated always as (to_tsvector('english', en)) stored;

copy documents (en, score) from '/data.tsv' csv header delimiter E'\t';

create index textsearch_index_en on documents
    using rum (textsearch_index_en_col rum_tsvector_addon_ops, score)
    with (attach = 'score', to = 'textsearch_index_en_col');

Queries:

select * from documents where textsearch_index_en_col @@ ('pet'::tsquery <-> ('dog'::tsquery || 'cat'::tsquery));
select * from documents where textsearch_index_en_col @@ (('pet'::tsquery <-> 'dog'::tsquery) || ('pet'::tsquery <-> 'cat'::tsquery));