我的实体中有一个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 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.
如何在休眠搜索中按枚举字段排序?
答案 0 :(得分:0)
您可能添加了sudo wget -O /etc/yum.repos.d/jenkins.repo \
https://pkg.jenkins.io/redhat-stable/jenkins.repo
sudo rpm --import https://pkg.jenkins.io/redhat-stable/jenkins.io.key
sudo yum upgrade
sudo yum install jenkins java-1.8.0-openjdk-devel
后忘了重新编制索引?
答案 1 :(得分:0)
通过在property.xml中设置<property name="hibernate.search.default.locking_strategy" value="none"/>
解决。我不知道如何,但是对我有用。