The idea, discussed during our last face-to-face meeting, was to be able to re-use search predicates or sorts because they may be expensive to build. That means returning {{SearchPredicate}} (or {{SearchSort}} , or {{SearchProjection}}) objects to the user, and allowing to pass passing them to the query DSL later.
Re-use would be allowed:
* between two search queries of the same search target * maybe, between two compatible search targets
What "compatible" means exactly has yet to be defined. Two identical search targets (same targeted indexes) are compatible for sure, so I think we should start with this definition, and extend it later if need be. We should also decide if we want to perform runtime checks when re-using
A preliminary implementation is already present in the proof-of-concept. However:
* the fact that predicates/sorts /projections can be re-used is not only partially tested . We'd have to check that the tests are sufficient. See {{org.hibernate.search.integrationtest.backend.tck.search.sort.SearchSortIT#lambda_caching}}, {{org.hibernate.search.integrationtest.backend.tck.search.predicate.SearchPredicateIT#match_caching_root}}, {{org.hibernate.search.integrationtest.backend.tck.search.predicate.SearchPredicateIT#match_caching_nonRoot}}. * we do not perform any runtime checks to validate that a given predicate/sort can be used in a given search query (that the search target it originated from is compatible with the one the query originated from) |
|