Waldemar Kłaczyński ( https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=557058%... ) *commented* on HSEARCH-3325 ( https://hibernate.atlassian.net/browse/HSEARCH-3325?atlOrigin=eyJpIjoiNTI... )
Re: Search 6 groundwork - Restore support for full-text filters ( https://hibernate.atlassian.net/browse/HSEARCH-3325?atlOrigin=eyJpIjoiNTI... )
Indeed, the filter from the previous version was not very configurable. I have slightly expanded the configuration. I have added the option to define additional parameters in the filter annotation. Parameters can be covered when constructing the query. I've added filter path information to the context. Now, for filters in flat and nested objects, a path path prefix is added. You can dynamically control the filter's configuration depending on how it is called.
@FullTextFilter(name= "match_fieldName" , factory = @FilterFactoryRef(type = TestFilterFactory.class), params = {
@FilterParam(name = "mode" , value = "extended" )
})
public class TestEntity implements Serializable {
public static class TestFilterFactory implements FilterFactory {
@Override
public SearchPredicate create(FilterFactoryContext ctx) {
SearchPredicate filter;
String nestedPath = ctx.getNestedPath();
String fieldPath = ctx.resolvePath( "fieldName" );
if ( nestedPath != null ) {
filter = ctx.predicate().nested()
.objectField( nestedPath )
.nest( f -> f
.match().field( fieldPath )
.matching( ctx.param( "match" ) ) )
.toPredicate();
}
else {
filter = ctx.predicate()
.match().field( fieldPath )
.matching( ctx.param( "match" ) )
.toPredicate();
}
return filter;
}
}
() -> scope.query()
.where( f -> {
return f.bool()
.minimumShouldMatchNumber( 3 )
.should( f.def( "match_fieldName" ).param( "match" , "blablabla" ) )
.should( f.def( "nested.match_fieldName" ).param( "match" , "blablabla" ) );
} ).toQuery()
( https://hibernate.atlassian.net/browse/HSEARCH-3325#add-comment?atlOrigin... ) Add Comment ( https://hibernate.atlassian.net/browse/HSEARCH-3325#add-comment?atlOrigin... )
Get Jira notifications on your phone! Download the Jira Cloud app for Android ( https://play.google.com/store/apps/details?id=com.atlassian.android.jira.... ) or iOS ( https://itunes.apple.com/app/apple-store/id1006972087?pt=696495&ct=EmailN... ) This message was sent by Atlassian Jira (v1001.0.0-SNAPSHOT#100121- sha1:e2c4b3b )