How to create an index on an integer json property in postgres
Try this instead:

CREATE INDEX user_reputation_idx ON users(cast("user"-&gt;&gt;'reputation' AS int));


The Postgres syntax shortcut :: for casts is not allowed without additional parentheses in an index definition (see @bma's comment). It works with the standard SQL function, though: cast(expression AS type) This is not related to the json type per se.

Either way, you can still use the syntax shortcut expression::type in expressions that utilize the index.