N1QL Sort by via Place holder

Identifiers, Filed names , reserve keywords can’t be used as place holders. Those must be static to optimizer decide on the plan during prepare time. Place holders are available only during execution. Only values can be place holders.

If you need dynamic key (dictionary access) order only (not direction of order). Query will do explicit order and optimizer can’t use index order.

SELECT *
FROM default AS d
WHERE …
ORDER BY d.[$3] DESC;

$3 must be string of field in the document, if not string it raises error.