Hi, David.
You are on the right track. You can query for contracts in the Active Contact Set, filtering by the contract template and/or parties. The response gives you both the contract id and the payload. For small apps, that may be sufficient. Obviously, that approach would not scale well.
For scalability, you may need to subscribe to updates on the ledger and write that data to a relational or document database. Your database would store the contract id and the payload. Your database would be a “projection” of the source data (which is on ledger).
This idea of keeping an indexed, searchable copy of the data is referred to in the docs as an Operational Data Store (ODS).
Digital Asset provides one such ODS named the Participant Query Store:
PQS provides a general-purpose, queryable view of ledger history and state suitable for a wide range of use cases. PQS is the recommended path for automation and integration components to access ledger data.
Also see A Docker Compose demo of the Participant Query Store (PQS)