java - 使用休眠搜索按枚举字段排序
问题描述
我的实体中有一个 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.
如何在休眠搜索中按枚举字段排序?
解决方案
<property name="hibernate.search.default.locking_strategy" value="none"/>
通过property.xml中的设置解决。我不知道如何,但它对我有用。
推荐阅读
- excel - Excel 条件格式 - 如果上面的未合并单元格符合条件,则最小值
- javascript - 当依赖于上下文状态时,反应停止组件的条件闪烁
- linux - 未能构建袖扣-2.2.1
- c# - 当我运行我的页面时,它返回一个 null 错误,就好像它没有捕获传入的信息一样
- c# - 如何使用流利断言断言一个集合是其他集合的子集合?
- bash - 当我想使用 bash 脚本在 tmux 中创建文件日志时应该怎么做?
- html - 如何使用 css 和 bootstrap 创建材料设计输入表单?
- ios - 每当收到通知时呈现 ViewController 会导致内存泄漏
- arrays - 表单数据以数组格式存储
- c++ - 链表 - 元素在删除后出现