With temporal workflow engine sdk, how can I search for previous submitted workflows with custom attributes attached?

with java sdk, how can i attach a list of name-value pairs of attribute value to a workflow so that later I can use the attributes to search and get the run id of the submitted workflow? where to find the example code for it? Thanks

Why do you need the run ID? In the majority of cases, the workflow ID is enough.

You can specify custom search attributes when starting the workflow. See setTypedSearchAttributes.