Hi @Namita_Jaokar ,
Unfortunately, I am really not familiar with the Elasticsearch Java client nor its API.
What I know though is that you should use the version that matches your stack version and do not mix 7.x and 8.x like you did.
Also, I would recommend trying to stick to the 8.x version to make your code more future-proof. While the 8.x Java client relies on the "REST high level" client, it provides a more modern API. see docs for more information here.