rum icon indicating copy to clipboard operation
rum copied to clipboard

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

Open 1Computer1 opened this issue 2 years ago • 3 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!

1Computer1 avatar Sep 23 '23 01:09 1Computer1

Please, provide us the test data and the query, which illustrate the problem.

On Sat, Sep 23, 2023 at 4:04 AM 1Computer1 @.***> wrote:

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!

— Reply to this email directly, view it on GitHub https://github.com/postgrespro/rum/issues/119, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABQURYXUHZ6NMRV4FD43A3DX3YYRHANCNFSM6AAAAAA5DZ4LYY . You are receiving this because you are subscribed to this thread.Message ID: @.***>

-- Postgres Professional: http://www.postgrespro.com The Russian Postgres Company

obartunov avatar Sep 23 '23 05:09 obartunov

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));

1Computer1 avatar Sep 23 '23 12:09 1Computer1

On Sat, Sep 23, 2023 at 8:34 AM 1Computer1 @.***> wrote:

Apologies, I couldn't reproduce it with a small set of data so this will be large file: data.zip https://github.com/postgrespro/rum/files/12706430/data.zip

I could reproduce it with a tiny test set, just replace your COPY command with:

insert into documents values ('the pet cat is in the shed',56);

Then just do set enable_seqscan=off; and run your given query.

I don't know the cause, though.

Message ID: @.***>

jeffjanes avatar Sep 24 '23 22:09 jeffjanes