Hello,
i would like to use boost in HS6 but i don’t find anything in documentation like this https://docs.jboss.org/hibernate/search/5.11/reference/en-US/html_single/#section-boosting in 5.11
thx
Hello,
i would like to use boost in HS6 but i don’t find anything in documentation like this https://docs.jboss.org/hibernate/search/5.11/reference/en-US/html_single/#section-boosting in 5.11
thx
Index-time boosting was deprecated a long time ago in Lucene and removed (I think?) in recent versions of Lucene, so it’s been removed from Hibernate Search as well.
You can use query-time boosting, just like in Hibernate Search 5, like this:
SearchResult<Book> query = searchSession.search( Book.class )
.predicate( f -> f.bool()
.should( f.match().onField( "someField" )
.matching( "some value" )
.boostedTo( 2.0f ) )
.should( f.match().onField( "someOtherField" )
.matching( "some other value" ) )
)
.fetch( 20 );
Or in the case of a multi-field predicate, like this:
SearchResult<Book> query = searchSession.search( Book.class )
.predicate( f -> f.match()
.onField( "someField" ).boostedTo( 2.0f )
.orField( "someOtherField" )
.matching( "some value" ) )
.fetch( 20 );
oh my bad, i didn’t knew the deprecation ! thanks for the answer