unfortunately, you cannot build state queries dynamically today. In theory it is possible to query the state database directly by using SQL, but we don’t recommend it. One reason is, that we might change the DB schema. Another reason is, that it is not completely trivial to build queries for search keys because we store them in an EAV table.
Regarding your second question: we don’t support filtering of persistent state attributes either.
All things considered, I would store your ticket resource in a relational database. Then, your requirements are easily implemented.