Hibernate search querying in MYSQL DB

In this case any ideal way to add fields into select dynamically, For example fields to be sent as response should be dynamic instead of manually adding like this –

Search.session(entityManager).search(ProductOrderEntity.class)
.extension(ElasticsearchExtension.get())
.select(f → f.composite(f.field(“directorName”, String.class),
f.field(“movies.title”, String.class).multi()))
.where(f → f.fromJson(json)).fetch(offset, limit);