我的实体中有一个ENUM字段
@Field(store=Store.NO,index=Index.YES,analyze=Analyze.NO)
@Enumerated(EnumType.STRING)
@FieldBridge(impl = EnumBridge.class)
@SortableField
private Status status;
我想通过这个字段对实体进行排序。因此,我在Hibernate搜索中创建了一个排序:
Sort sort = qb
.sort()
.byDistance()
.onField("location.location")
.fromLatitude(sfq.getTheCenterLatitude())
.andLongitude(sfq.getTheCenterLongitude())
.andByField("status")
.createSort();
(我也按距离排序,但没关系(
但是,当我尝试搜索时,我看到了这个错误
ERROR [io.undertow.request] (default task-1) UT005023: Exception handling request to /api/search/: org.jboss.resteasy.spi.UnhandledException: java.lang.IllegalStateException: unexpected docvalues type NONE for field 'status' (expected=SORTED). Use UninvertingReader or index with docvalues
Caused by: java.lang.IllegalStateException: unexpected docvalues type NONE for field 'status' (expected=SORTED). Use UninvertingReader or index with docvalues.
如何在hibernate搜索中按枚举字段排序?
添加@SortableField
后,您可能忘记重新索引了?
通过在property.xml中设置<property name="hibernate.search.default.locking_strategy" value="none"/>
来解决。我不知道如何解决,但它对我有效。