Can JSONB fields be indexed in YugabyteDB YSQL?

Is it possible to index JSONB fields in YugabyteDB YSQL?

YSQL uses Postgresql upper halp, and we support expression indexes.
See example to create an index on cow field of jsonb column animal :

create table farm(id BIGSERIAL, animal JSONB);
CREATE INDEX animal_index ON farm (((animal ->> 'cow')::int));
select * from farm where (animal->>'cow')::int = 3;
1 Like