Temporal Java API Search APIS

Hello

We are trying to search our running and complete workflows and want to be able to generate reports on them. Is there an api which would return a result set which consists of custom search attributes? We are using elasticearch for advanced visibility.
Our workflows are long running journeys and journeyVersion is for example a custom search attribute we have defined. JourneyState is another custom search attribute we have defined. One of our requirements is to be able to see the distribution of all running workflows by their JourneyState and Journey version. The result set/table we are after is something like this:

JourneyState JourneyVersion CountOfWorkflows
basic_info_checked v4 5
basic_info_checked v3 4
confirmed v3 3
confirmed v4 2
app_sent v2 10

A view like this will give us the insight that there are no v1 Journeys running and we can decommission it. It would also give more insight into which version of the Journey is close to be deprecated etc …

We could use listWorkflowExecutions to query the workflows but I can’t see achieving the above with that api unless I am missing something. I’d be grateful if you could let me know if I am missing something.

Another question I have is, I see there is a method called .setField() on ListWorkflowExecutionsRequest, what is the use of this method?

And lastly whats the difference between listWorkflowExecutions and scanWorkflowExecutions ? Which one is better in which scenario? Is countWorkflowExecutions superior to the above if we are only interested in count?

Thank you