Search code examples
postgresqljsonb

Postgres jsonb Index Format


I'm trying to find the name for these type of indexes. I looked on Google and Postgres documentation and they have nothing on what Value-> operator does. And how its different from a regular: -> SomeInt.

CREATE INDEX "someIndex" ON "me-db"."someTable" USING btree ((((jsondata -> 'SomeInt'::text) -> 'HasValue'::text)))
CREATE INDEX "someIndex2" ON "me-db"."someTable" USING btree ((((jsondata -> 'SomeInt'::text) -> 'Value'::text)))

What are the names for ->HasValue and ->Value operators? How is ->Value different from ->Field.


Solution

  • These are the key names in you json structure. If you wrap one with another it means you have a nested json like this (for the above lines):

    {"SomeInt": {"HasValue": 1, "Value": 2}}