We're updating the issue view to help you get more done. 

Allow to perform some operations without an ORM session in the ORM mapper

Description

Sometimes, one needs to perform search queries so often that even creating an ORM session requires too much resources. The search might not need ORM at all, for example because it's only performing projections.

We should provide a way to perform a search query, or any operation that doesn't really require an ORM session, without forcing the user to create a SearchSession.

We would first need to introduce an entry point to Hibernate Search APIs that isn't a session. This entry point should be added to the ORM mapper module. For example an interface named SearchSessionFactory, or maybe better SearchMapping, accessible by calling Search.getSearchSessionFactory( ormSessionFactory ) or Search.getSearchMapping( ormSessionFactory ).

This interface would expose .search and .scope methods, similarly to SearchSession, but these methods would return interfaces that do not offer as many options. In particular .search( ... ).asEntity() should not be possible, since we don't have a session. Similarly, the scope may not offer all operations that are available from a session.

Alternatively, we could expose access to IndexSearchScope directly from the SearchMapping
The most obvious solution would be to provide a Search.getMapping() method that returns a SearchMapping, which allows to call .search(Class<?> ... classes) to start building a search query, but with less options than the .search(...) from the SearchSession, since

Environment

None

Status

Assignee

Unassigned

Reporter

Yoann Rodière

Labels

None

Suitable for new contributors

None

Pull Request

None

Feedback Requested

None

Components

Fix versions

Priority

Major