[hibernate-issues] [JIRA] (HSEARCH-3325) Search 6 groundwork - Restore support for full-text filters

Waldemar Kłaczyński (JIRA) jira at hibernate.atlassian.net
Thu Mar 12 18:19:55 EDT 2020


Waldemar Kłaczyński ( https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=557058%3A77e50cac-bda3-4af4-9bb3-6461f4d10eea ) *commented* on HSEARCH-3325 ( https://hibernate.atlassian.net/browse/HSEARCH-3325?atlOrigin=eyJpIjoiNTI4OTNhNjQxYjI0NDFjMDg3OGE3NzYyMzNhYjFkOGMiLCJwIjoiaiJ9 )

Re: Search 6 groundwork - Restore support for full-text filters ( https://hibernate.atlassian.net/browse/HSEARCH-3325?atlOrigin=eyJpIjoiNTI4OTNhNjQxYjI0NDFjMDg3OGE3NzYyMzNhYjFkOGMiLCJwIjoiaiJ9 )

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=eyJpIjoiNTI4OTNhNjQxYjI0NDFjMDg3OGE3NzYyMzNhYjFkOGMiLCJwIjoiaiJ9 ) Add Comment ( https://hibernate.atlassian.net/browse/HSEARCH-3325#add-comment?atlOrigin=eyJpIjoiNTI4OTNhNjQxYjI0NDFjMDg3OGE3NzYyMzNhYjFkOGMiLCJwIjoiaiJ9 )

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.core&referrer=utm_source%3DNotificationLink%26utm_medium%3DEmail ) or iOS ( https://itunes.apple.com/app/apple-store/id1006972087?pt=696495&ct=EmailNotificationLink&mt=8 ) This message was sent by Atlassian Jira (v1001.0.0-SNAPSHOT#100121- sha1:e2c4b3b )
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/hibernate-issues/attachments/20200312/55fd9269/attachment.html 


More information about the hibernate-issues mailing list