New operators and class for jsonb with gin indexing

From: Luka Zivkovic <lukazivkovic58(at)gmail(dot)com>
To: pgsql-general(at)lists(dot)postgresql(dot)org
Subject: New operators and class for jsonb with gin indexing
Date: 2021-02-23 14:30:09
Message-ID: CA+=JdnNC-Z1hQRyf1XkN_usqDP8ctbdsizfkin3NF0i9-C+D7g@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hello all!

I am having problems applying gin indexing to my new operator class for
type jsonb.
I created an operator that can query(jsonb column) keys and dates where
dates are more than, less than, equal and not equal to the one provided
inside another jsonb.
Because I want to make it use index search and not sequential search, I
wanted to use gin indexing, but it says that i'm missing support functions.
Did anybody try to do something like this? I searched everywhere online,
and I didn't see an example of how they should look like. This is how i
created an operator class

CREATE OPERATOR CLASS custom_jsonb_dates_operators FOR TYPE jsonb
USING gin AS
OPERATOR 1 #>? (jsonb, jsonb),
OPERATOR 2 #<? (jsonb, jsonb),
OPERATOR 3 #=? (jsonb, jsonb),
OPERATOR 4 #!=? (jsonb, jsonb)
After this, when i created an index with this operator class, i got the
following error:

missing support function 2 for attribute 1 of index "idx_name"

I tried writing my own support functions, but none worked(after creating an
index, it just never returned any results.

Thanks,
Luka Zivkovic

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Ron 2021-02-23 14:32:38 Re: yum update for postgresql rpms
Previous Message Haas, Scott 2021-02-23 14:22:00 Re: yum update for postgresql rpms