Reactive APIs have been considered, but are not priority in Hibernate Search right now, as we’re working on asynchronous indexing ([HSEARCH-3280] Simple, asynchronous, distributed reindexing relying on the database only (without any extra infrastructure) - Hibernate JIRA).
There is a ticket, though I intended to start with simpler things than scroll
(such as a fetchAsync()
that returns a CompletableFuture<SearchResult<T>>
): [HSEARCH-3322] Async, reactive-friendly methods for simple search and indexing - Hibernate JIRA
That being said, I think this would mostly make sense for queries that do not load entities (projections only). When it comes to loading entities, to be honest I have no idea whether a Publisher
can be implemented correctly with Hibernate ORM, because ORM is blocking by nature. There’s a whole new project to do reactive programming with ORM, called Hibernate Reactive. Maybe we would need an integration between Hibernate Reactive and Hibernate Search.
So, yeah. One day, but definitely not right now
I’m curious though, are you sure you need the full complexity of Publisher
/Subscriber
? Any reason a simple loop, or a callback passed to a method implementing the loop, is not enough?