[hibernate-issues] [Hibernate-JIRA] Commented: (HSEARCH-871) Only the last enabled FullTextFilter is in effect if multiple FullTextFilters of the same type, different parameters are enabled

Hardy Ferentschik (JIRA) noreply at atlassian.com
Thu Sep 22 11:50:39 EDT 2011


    [ http://opensource.atlassian.com/projects/hibernate/browse/HSEARCH-871?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=43673#comment-43673 ] 

Hardy Ferentschik commented on HSEARCH-871:
-------------------------------------------

I don't think this is a bug actually. The filter instances are maintained by name within the fulltext query. In your example you are effectively retrieving the instance twice and just updating the parameters. Once the query executes only the last set of parameters apply.
You could either specify the filter twice:
{code}
@FullTextFilterDefs({
		@FullTextFilterDef(name = "bestDriver", impl = BestDriversFilter.class, cache = FilterCacheModeType.NONE),
		//actual Filter implementation
		@FullTextFilterDef(name = "security",
				impl = SecurityFilterFactory.class,
				cache = FilterCacheModeType.INSTANCE_AND_DOCIDSETRESULTS),
		@FullTextFilterDef(name = "fieldConstraintFilter-1",
				impl = FieldConstraintFilter.class,
				cache = FilterCacheModeType.INSTANCE_AND_DOCIDSETRESULTS),
		@FullTextFilterDef(name = "fieldConstraintFilter-2",
				impl = FieldConstraintFilter.class,
				cache = FilterCacheModeType.INSTANCE_AND_DOCIDSETRESULTS),
		//Filter factory with parameters
		@FullTextFilterDef(name = "cacheresultstest",
				impl = ExcludeAllFilterFactory.class,
				cache = FilterCacheModeType.INSTANCE_AND_DOCIDSETRESULTS),
		@FullTextFilterDef(name = "cacheinstancetest",
				impl = InstanceBasedExcludeAllFilter.class,
				cache = FilterCacheModeType.INSTANCE_ONLY),
		@FullTextFilterDef(name = "empty",
				impl = NullReturningEmptyFilter.class,
				cache = FilterCacheModeType.INSTANCE_ONLY)
})
{code}

or you pass a list of string as value parameter.

> Only the last enabled FullTextFilter is in effect if multiple FullTextFilters of the same type, different parameters are enabled
> --------------------------------------------------------------------------------------------------------------------------------
>
>                 Key: HSEARCH-871
>                 URL: http://opensource.atlassian.com/projects/hibernate/browse/HSEARCH-871
>             Project: Hibernate Search
>          Issue Type: Bug
>          Components: query
>    Affects Versions: 3.4.0.Final
>         Environment: -
>            Reporter: Elmer van Chastelet
>            Assignee: Hardy Ferentschik
>             Fix For: 4.0.0.Beta2
>
>         Attachments: FilterTestAdded.diff
>
>
> The following test fails, it only seems to apply the last filter. Attached is a patch that adds this test and changes to the domain/filters.
> {code:java}
> ftQuery = s.createFullTextQuery( query, Driver.class );
> ftQuery.enableFullTextFilter( "fieldConstraintFilter")
> 	.setParameter( "field", "teacher" )
> 	.setParameter( "value", "andre" );
> ftQuery.enableFullTextFilter( "fieldConstraintFilter")
> 	.setParameter( "field", "teacher" )
> 	.setParameter( "value", "aaron" );
> assertEquals("Should apply both filters resulting in 0 results", 0, ftQuery.getResultSize() );
> {code} 

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

        


More information about the hibernate-issues mailing list