| Solved in Search 6 by introducing the intermediate concept of SearchTarget, from which both predicates and the search query will be built. The targeted types do not have to be mentioned twice anymore, only once when building the search target, which will then be used as a starting point from By using lambdas to build predicates, the search target can be avoided and you still avoid mentioning the targeted types twice. Also, you do not need to have multiple query builders anymore, since the SearchTarget will work for any field of any targeted index (and it will check the fields are defined consistently in targeted indexes). Example:
FullTextQuery<Object> query = fullTextSession.search( Arrays.asList( Book.class, Author.class ) ).query()
.asEntity()
.predicate( f -> f.bool()
.should( f.match().onFields( "title" ).matching( "refactor" ) )
.should( f.match().onFields( "name" ).matching( "john" ) )
.build();
List<Object> result = query.getResultList();
This was already solved in HSEARCH-3302 Closed , when working on the proof-of-concept, IIRC. |