Hibernate Search QueryBuilder:查询非实体字段
我试图将 Hibernate Search 中的 QueryBuilder 与一个字段一起使用,该字段不是相应实体的属性,而是使用 ClassBridge 动态构建的。我可以这样做吗?
QueryBuilder qb = fullTextEntityManager.getSearchFactory().
buildQueryBuilder().forEntity(Publication.class).get();
....
Query query = qb.keyword().onField("title").matching("Lärm").createQuery();
字段“title”不是 Publication 类的一部分,但在 Lucene 索引中可用(并且可搜索)。
更新: 根据 https://forum.hibernate.org/viewtopic.php?f =9&t=1008943,以下有效:
QueryBuilder qb = fullTextEntityManager.getSearchFactory().
buildQueryBuilder().forEntity(Publication.class).get();
....
Query query = qb.keyword().onField("title").ignoreFieldBridge().matching("Lärm").createQuery();
(ignoreFieldBridge做到了这一点)
I am trying to use the QueryBuilder from Hibernate Search with a field which is not a property of the respective Entity but rather constructed on the fly using an ClassBridge. Can I do that?
QueryBuilder qb = fullTextEntityManager.getSearchFactory().
buildQueryBuilder().forEntity(Publication.class).get();
....
Query query = qb.keyword().onField("title").matching("Lärm").createQuery();
The field "title" is not part of the Publication class but is available (and searchable) in the Lucene Index.
UPDATE:
According to https://forum.hibernate.org/viewtopic.php?f=9&t=1008943, the following works:
QueryBuilder qb = fullTextEntityManager.getSearchFactory().
buildQueryBuilder().forEntity(Publication.class).get();
....
Query query = qb.keyword().onField("title").ignoreFieldBridge().matching("Lärm").createQuery();
(ignoreFieldBridge did the trick)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论