Description
Description
Creating this for tracking, to assess demand and collect suggestions.
We currently have a Panache extensions for Hibernate ORM, one for Hibernate Reactive, and one for MongoDB.
We don't have one for Hibernate Search, despite Hibernate Search exposing very advanced and useful search features. We should aim to change that.
The idea would be to allow an extra interface on Panache repositories, exposing a search()
method which can then be used this way:
List<Book> hits = Book.search()
.where( f -> f.match().field( "title" ).matching( "robot" ) )
.find()
.page( Page.of( 0, 20 ) )
.list();
With plenty of variants, e.g. to project on an entity reference only:
List<EntityReference> hits = Book.search()
.select( f -> f.entityReference() )
.where( f -> f.match().field( "title" ).matching( "robot" ) )
.find()
.page( Page.of( 0, 20 ) )
.list();
For the active record pattern, we'll probably need a dedicated superclass, e.g. PanacheSearchableEntityBase
.
Implementation ideas
See https://quarkusio.zulipchat.com/#narrow/stream/187030-users/topic/case.20-insenstive-query-panache/near/207954740 for the whole discussion
In particular:
As to how we'd expose it, I'd say:
- create a separate extension hibernate-search-orm-elasticsearch-panache
- add an SPI in hibernate-orm-panache to allow other extensions to register extended PanacheEntityBase/PanacheRepository types
- create a
PanacheSearchableEntityBase
and register it to thehibernate-orm-panache
extension so that it triggers the correct bytecode generation- create a
PanacheSearchableRepository
interface and register it in a similar way- Later, we might need to support multiple extensions in the same entity class, for example to support both Envers and Search. For these (admittedly rare) cases, I'd be inclined to expose a method like this in PanacheEntityBase:
static <T> T extension(Class<T> extension)
. A user would select one "main" base class, e.g.PanacheEnversEntityBase
, and to access other extensions they would writeMyEntity.extension(PanacheSearch.class).search()
.
Note there is a (very early) prototype already available here: https://github.com/yrodiere/hibernate-search/tree/panache