How to set num_shards and num_replicas in the latest Java client?

In the older version replaced by OpenSearch Java, the ability to configure an index for its replicas and shards has disappeared. It was in the older version. How do I set the number of shards?

Should mention, I’m using the latest 2.0 version.

says that I can put those values in the mappings file. Is that the only way to set these values?