The only queries in the samples are getting all states by class or using LinearStateQueryCriteria to get via id.
There are lots of other different query options available
https://docs.corda.net/docs/corda-os/4.8/api-vault-query.html#querycriteria-interface
The documentation is lacking in how to do some of these which has caused confusion:
https://stackoverflow.com/q/60342424/1000011