Bean configurer for Hibernate Search client

Dears,

Very briefly, I need to inject the API key into the Hibernate Search client.

To accomplish this I implement a BeanConfigurer and ElasticsearchHttpClientConfigurer. But in the BeanConfigurer this:

context.define(ElasticsearchHttpClientConfigurer.class,
BeanReference.of(ElasticsearchHttpClientConfigurerImpl.class));

Gives an ‘Incompatible equality constraint’. ElasticsearchHttpClientConfigurerImpl implements ElasticsearchHttpClientConfigurer of course :wink:

Perhaps there is another way to configure my Hibernate Search client with the Authorization key?

Version is 6.2.1, Java 11.

Cheers,
Michael

Hi,

Seems the SPI is a bit too strict indeed :confused:

How do you intend to retrieve the configurer? As a Spring/CDI bean? By direct constructor instantiation?

I created [HSEARCH-5034] - Hibernate JIRA to relax the SPI constraints.

In the meantime, I’d recommend simply casting. It’s safe, because BeanReference<T> is covariant in T:

context.define(ElasticsearchHttpClientConfigurer.class,
(BeanReference<ElasticsearchHttpClientConfigurer>) BeanReference.of(ElasticsearchHttpClientConfigurerImpl.class));