Hibernate Search + Elastic Search indexing/search taking too much time

You mean sending search queries to Elasticsearch via curl or similar, i.e. direct REST requests, is slow too? If that’s the case, there isn’t much Hibernate Search can do to help. Your Elasticsearch cluster is slow, so you should look into solving that first.

Perhaps the Elasticsearch forums will be have some advice for you. Post something there and maybe someone will help, but be sure to include more information, like the specs of your server(s), the request you sent and how slow it was, the current load including other applications, your custom configuration on the Elasticsearch side, etc.

You did not say which version of Hibernate Search you are using, so I will assume 6, the latest.

See batchSizeToLoadObjects here to configure how many entities are loaded in each query to the database.

See hibernate.search.backend.indexing.max_bulk_size here to configure how many documents (at most) are sent to the Elasticsearch cluster in each HTTP request. A word of warning: multiple requests can be sent in parallel. If you increase the bulk size or parallelism too much, there’s a risk of overloading Elasticsearch if it doesn’t have enough memory available to handle your large bulks, and in that case the indexing will start failing.

In Hibernate Search 5, the maximum Elasticsearch bulk size cannot be configured and is always 250.