Hibernate Search QueryBuilder: query for non-entity field

I am trying to use QueryBuilder from Hibernate Search with a field that is not a property of the corresponding object, but rather built on the fly using ClassBridge. Can I do it?

QueryBuilder qb = fullTextEntityManager.getSearchFactory(). buildQueryBuilder().forEntity(Publication.class).get(); .... Query query = qb.keyword().onField("title").matching("Lรคrm").createQuery(); 

The "title" field 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)

+6
source share

Source: https://habr.com/ru/post/891473/


All Articles