Connect Hibernate Search 6.1.5.Final + Elasticsearch 8.2.X using a Token

Is there any way to connect to elasticsearch 8.2.x using HibernateSearch connection using an API KEY (base64):xxxxxxxxxxxxxxxx instead of using login and password using spring framework ?

As explained in the following documentation by implementing : Hibernate Elasticsearch - set connection/username/password programmaticly
to configure the underlying Apache HTTP Client, and registering it using the org.hibernate.search.engine.environment.bean.spi.BeanConfigurationContext
I noticed that somthing is moved between the last versions of hibernatesrach, unless i am mistaken,the mothod BeanConfigurationContext.assignRole() is longer exists in final version of hibernatesearch

Is there any way we can currently achieve this?

The method you linked to is still doable (though some method names have changed), but it’s no longer necessary as there is a simpler solution: just set configuration property hibernate.search.backend.client.configurer to a reference to your custom configurer.

See Hibernate Search 7.0.0.Final: Reference Documentation

Also, for the common use case of connection to AWS Elasticsearch Service / AWS OpenSearch Service, there is a dedicated solution: Hibernate Search 7.0.0.Final: Reference Documentation

1 Like

Thanks, i will look into it.