Sorting not working for Double type property? Also issue with `entityManager`

Here I am gonna enable sort on a field with double field, so in Entity Class, I code like

    @Column(name = "price")
    @Fields({
            @Field(name = "listingPriceFrom", analyze = Analyze.NO, index = Index.YES)
    })
    @SortableField(forField = "listingPriceFrom")
    private Double listingPriceFrom;

And this is a data lib worked as a artefact.

In ES engine, this field’s structure is like

"listingPriceFrom": {
       "type": "double"
}

Then another service pulls this data lib in from NEXUS, after that, when spring boot starts the service, it shows the error message:

:18516:00:34.134 [restartedMain] DEBUG o.h.internal.SessionFactoryImpl [SessionFactoryImpl.java:741]- HHH000031: Closing
:74116:00:34.136 [restartedMain] DEBUG o.h.internal.SessionFactoryRegistry [SessionFactoryRegistry.java:52]- Initializing SessionFactoryRegistry : org.hibernate.internal.SessionFactoryRegistry@646e8d3d
:5216:00:34.137 [restartedMain] DEBUG o.hibernate.engine.spi.CascadeStyles [CascadeStyles.java:268]- External cascade style registration [persist : STYLE_PERSIST] overrode base registration [STYLE_PERSIST_SKIPLAZY]
:26816:00:34.137 [restartedMain] DEBUG o.h.s.i.AbstractServiceRegistryImpl [AbstractServiceRegistryImpl.java:414]- Implicitly destroying ServiceRegistry on de-registration of all child ServiceRegistries
:41416:00:34.137 [restartedMain] DEBUG o.h.b.r.i.BootstrapServiceRegistryImpl [BootstrapServiceRegistryImpl.java:295]- Implicitly destroying Boot-strap registry on de-registration of all child ServiceRegistries
:29516:00:34.137 [restartedMain] DEBUG o.hibernate.engine.spi.CascadeStyles [CascadeStyles.java:268]- External cascade style registration [persist : STYLE_PERSIST] overrode base registration [STYLE_PERSIST]
:26816:00:34.138 [restartedMain] WARN  o.s.b.w.s.c.AnnotationConfigServletWebServerApplicationContext [Jdk14Logger.java:87]- Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaConfiguration.class]: Invocation of init method failed; nested exception is javax.persistence.PersistenceException: [PersistenceUnit: default] Unable to build Hibernate SessionFactory; nested exception is java.lang.NullPointerException
:8716:00:34.138 [restartedMain] INFO  com.zaxxer.hikari.HikariDataSource [HikariDataSource.java:381]- HikariPool-1 - Shutdown initiated...
:38116:00:34.139 [restartedMain] DEBUG com.zaxxer.hikari.pool.HikariPool [HikariPool.java:404]- HikariPool-1 - Before shutdown stats (total=1, active=0, idle=1, waiting=0)
:40416:00:34.139 [HikariPool-1 connection closer] DEBUG com.zaxxer.hikari.pool.PoolBase [PoolBase.java:127]- HikariPool-1 - Closing connection com.mysql.cj.jdbc.ConnectionImpl@3ba2fa0d: (connection evicted)
:12716:00:34.141 [restartedMain] DEBUG com.zaxxer.hikari.pool.HikariPool [HikariPool.java:404]- HikariPool-1 - After shutdown stats (total=0, active=0, idle=0, waiting=0)
:40416:00:34.141 [restartedMain] INFO  com.zaxxer.hikari.HikariDataSource [HikariDataSource.java:383]- HikariPool-1 - Shutdown completed.
:38316:00:34.144 [restartedMain] INFO  o.a.catalina.core.StandardService [DirectJDKLog.java:180]- Stopping service [Tomcat]

No idea why, but I am sure it only deals with this Double field, if we remove Fields line and SortableField in entity class, pull that in, service could start as normal as expected.

By the way, I’ve tried adding a field, like

    @FieldBridge(impl = DoubleBridge.class)

but it seems wrong actually cuz it turns out to be a sorting based on the string instead of a number, right?

The searching class is like:
image

Anyone can help?

Anyone can help?

I’m afraid not. Your logs mention a java.lang.NullPointerException but do not show the stack trace. Please show us the stack trace? It might be a bit higher in your logs.

Ideally, just paste your whole logs to pastebin and give us the link.

Please also tell us the version of Hibernate Search and Hibernate ORM you’re using.

Thank you yrodiere, this is stacktrace log:
https://pastebin.com/1pk72N9V

And this is the version for ORM and Search

compile "org.hibernate:hibernate-core:5.2.16.Final"
compile "org.hibernate:hibernate-entitymanager:5.2.16.Final"
compile "org.hibernate:hibernate-search-orm:5.9.1.Final"
compile "org.hibernate:hibernate-search-elasticsearch:5.9.1.Final"

So, first, this means trouble:

:7821:02:28.452 [restartedMain] WARN  o.h.s.e.d.i.DefaultElasticsearchDialectFactory [DefaultElasticsearchDialectFactory.java:57]- HSEARCH400085: Hibernate Search may not work correctly, because an unknown Elasticsearch version runs on the Elasticsearch cluster: '6.2.4'.

Hibernate Search 5.x is only known to work well with Elasticsearch 5.6.x; Elasticsearch 6.x may not work correctly. You’ve been warned.

That being said, the logs do not include any stack trace, so they are not useful as is. It looks like other people had this issue, maybe this is the solution to get stack traces in your logs.

Thank you yrodiere for your advice, I am gonna try that.
By the way, what HS version do you suggest to use, currently our AWS elastic search version is 6.2.3.

AWS supports a whole range of versions, from 1.3 to 6.4. For now, with Hibernate Search, I would recommend 5.6.

That being said, I’m aware 5.6 is nearing its end of life, so I suppose that a well-tested application could try ES6. We’re aiming to add support for ES6 in Hibernate Search 6.0, and so far we haven’t found any difference (except, of course, the lack of support for multiple types per index).