Another situation ![]()
This won’t compile because I get this error:
Type mismatch: cannot convert from PredicateFinalStep to SearchPredicate
import org.hibernate.search.engine.search.predicate.SearchPredicate;
import org.hibernate.search.engine.search.predicate.dsl.SearchPredicateFactory;
import org.hibernate.search.mapper.orm.session.SearchSession;
// ...
SearchPredicateFactory pf = searchSession.scope( Article.class ).predicate();
List<SearchPredicate> predicates = new ArrayList<>();
// ... build the list of predicates ...
SearchPredicate classPredicate = pf.bool( b -> {
for( SearchPredicate predicate : predicates ) {
b.should( predicate );
}
b.minimumShouldMatchNumber( 1 );
} );
When I put a cast in front of pf.bool() the error is gone.
The example in migration guide does not have cast and I’m not sure I’m doing it right.
Since I have tons of code to convert, I’m not able to test it and I guess I won’t be able for days and days.
SearchPredicate classPredicate = (SearchPredicate) pf.bool( b -> {
for( SearchPredicate predicate : predicates ) {
b.should( predicate );
}
b.minimumShouldMatchNumber( 1 );
} );