Hibernate Search QueryBuilder: query for non-entity field [closed]
Asked Answered
F

0

6

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)

Forelimb answered 27/6, 2011 at 17:28 Comment(3)
Ok, found the solution: see editForelimb
Do feel free to answer your own question if nobody else has. It could be helpful to others :)Togetherness
Yes please, make an answer and accept it so you question can be removed from Unanswered questions.Mariandi

© 2022 - 2024 — McMap. All rights reserved.