Hi,
I am using hibernate search in version 7.1.1.Final with elastic search as the backend and SpringBoot 3.3.3.
The index-size is: 300.000 documents, 300MB
Because I have the same issue as mentioned here (“timeout during reindex”):
I want to increase the timeout-settings to prevent an exception during the “_delete_by_query” request.
Increasing the default value of 30.000ms should fix it, but assigning the following env-variables has no effect.
"SPRING_JPA_PROPERTIES_HIBERNATE_SEARCH_BACKEND_READ_TIMEOUT" : 900000,
"SPRING_JPA_PROPERTIES_HIBERNATE_SEARCH_BACKEND_REQUEST_TIMEOUT" : 900000,
"SPRING_JPA_PROPERTIES_HIBERNATE_SEARCH_BACKEND_CONNECTION_TIMEOUT" : 900000,
Using the variables directly in application.yml
works. Why?
spring.jpa.properties.hibernate.search.backend.request_timeout: 900000
spring.jpa.properties.hibernate.search.backend.connection_timeout: 900000
spring.jpa.properties.hibernate.search.backend.read_timeout: 900000
During debugging in: ElasticsearchClientImpl
and ElasticsearchClientFactoryImpl
I can see that the correct value is set (application.yml
) and not set (env-variable) .
Is this a feature or a bug?
Please help and thx in advance
Olli
mbekhta
September 16, 2024, 7:24am
2
Hey @OllisGit
with Spring it’s whatever it decided to pass over to Hibernate ORM is what we get here (btw that’s why you have to prefix the properties with spring.jpa.properties.
)… see spring-framework/spring-orm/src/main/java/org/springframework/orm/jpa/vendor/SpringHibernateJpaPersistenceProvider.java at d3755aba0619152e0c04f52ea72815cace270537 · spring-projects/spring-framework · GitHub
so if you expect that env variables should work the same as properties in a file, then it may be a problem on the Spring side. As far as Hibernate Search is concerned – it doesn’t lookup env variables (especially some-framework-specific ones) to get its configuration.
Hi @mbekhta ,
thanks a lot for the answer. It helps.
I found other posts where people have issues with underscore based env-variables: java - How to set a Spring Boot property with an underscore in its name via Environment Variables? - Stack Overflow
So, my working solution is now to “substitute” the underscore keys like this:
application.yml
spring.jpa.properties.hibernate.search.backend.request_timeout: ${myapp.hibernatesearch.timeout}
spring.jpa.properties.hibernate.search.backend.connection_timeout: ${myapp.hibernatesearch.timeout}
spring.jpa.properties.hibernate.search.backend.read_timeout: ${myapp.hibernatesearch.timeout}
...
myapp:
# default hibernate-search timeout (1 min)
hibernatesearch.timeout: 60000
and now I can overwrite the value via this env-variable:
export MYAPP_HIBERNATESEARCH_TIMEOUT=120000
Have a nice day
Olli