SearchResponse<ObjectNode> searchResponse = elasticsearchClient.search(req -> req.index(index)
.from((pageNumber - 1) * pageSize)
.size(pageSize)
.source(SourceConfig.of(s -> s.filter(f -> f.includes(queryDto.getQuery().getSelect()))))
.query(subQuery -> subQuery.bool(bool -> bool
.must(termsQueryMustList)
.mustNot(termsQueryMustNotList)))
.sort(sortOptions),
ObjectNode.class);
How can I build the search request query dynamically by adding .sort() or .from() or .size() only if sortOptions and pageSize are available.