2 Expanded answer
source | link

As @bma explained in a comment, your index will work as-is, if you add double parentheses around the entire JSON definition:

CREATE INDEX user_reputation_idx ON users((("user"->>'reputation')::int));

Make sure you consistently use the JSON text notation [->>], not the JSON object notation [->]. That includes, in the index and when referencing the field in a query, or the index won't be used.

Alternatively, you can consistently use the object notation [->]. You just have to stick to one or the other, don't mix them.

As @bma explained in a comment, your index will work as-is, if you add double parentheses around the entire JSON definition:

CREATE INDEX user_reputation_idx ON users((("user"->>'reputation')::int));

Make sure you use the JSON text notation [->>], not the JSON object notation [->]. That includes when referencing the field in a query, or the index won't be used.

As @bma explained in a comment, your index will work as-is, if you add double parentheses around the entire JSON definition:

CREATE INDEX user_reputation_idx ON users((("user"->>'reputation')::int));

Make sure you consistently use the JSON text notation [->>], not the JSON object notation [->], in the index and when referencing the field in a query, or the index won't be used.

Alternatively, you can consistently use the object notation [->]. You just have to stick to one or the other, don't mix them.

1
source | link

As @bma explained in a comment, your index will work as-is, if you add double parentheses around the entire JSON definition:

CREATE INDEX user_reputation_idx ON users((("user"->>'reputation')::int));

Make sure you use the JSON text notation [->>], not the JSON object notation [->]. That includes when referencing the field in a query, or the index won't be used.