Currently SearchScope is a very niche interface, most users being expected to use the SearchSession methods that simply delegate to the scope.
The main (only?) use for SearchScope is when users want to build re-usable predicates/sorts/projections etc. Then, using the scope, they can build objects that they'll be able to re-use in other
These objects are session-independent, so they could be used from one session to another, but unfortunately the scope is not, which makes creating re-usable objects rather weird: you have to open a session for something that doesn't need a session.
It would be nice if we could make SearchScope session-independent. Basically the SearchScope would only represent a set of indexed types, and expose operations on this set. Only some operations will require a session, which will be passed as a parameter: search() would become search(EntityManager), massIndexer() would become massIndexer(EntityManager), and so on.
The SearchScope will no longer be retrieved from the SearchSession. Instead, we will introduce a SearchMapping interface (as mentioned in ), and retrieving a scope will go something like this:
Which is really not far from what we currently have:
Nothing will change on SearchSession, as implementations will only pass an additional parameter to the scope, which will be transparent to users. We will just remove (or at least deprecate for later removal) the .scope() methods on SearchSession.