Just to make the DSL less verbose, we should allow the mappers to specify a default "projection", so that we can write something like this:
return Search.getSearchSession(em).search(Book.class)
.predicate(f -> f.simpleQueryString().onFields("title").matching(pattern))
.sort(f -> f.byField("title_sort"))
.fetchHits();
And if the user really needs to change the projection, they can still call the asProjection method explicitly:
return Search.getSearchSession(em).search(Book.class)
.asProjection(f -> ...)
.predicate(f -> f.simpleQueryString().onFields("title").matching(pattern))
.sort(f -> f.byField("title_sort"))
.fetchHits();
|