[hibernate-issues] [Hibernate-JIRA] Commented: (HSEARCH-770) Range facets: .below on numeric null values (AssertionFailure: Unsupported range type)

Hardy Ferentschik (JIRA) noreply at atlassian.com
Thu Aug 11 12:54:03 EDT 2011


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

Hardy Ferentschik commented on HSEARCH-770:
-------------------------------------------

Hi Elmer,

thanks again for your help. You are really pointing out two issues. The first is the _AssertionFailure_ which indeed can be fixed by using _getNonNullMinOrMax()_.
The problem with 'null' is another issue and reveals a problem with the current implementation of faceting using the _FacetingCollector_. The _FieldCache_ for numeric values uses primitive types which means the fact that there were null values is effectively lost. The array will contain the value 0 and that's what's counted. When you then select the facet a _RangeQuery_ is executed selecting the values in the range. Since _null_ null values are not even indexed they won't be retrieved. 
The best solution in the long term is to switch to the new Lucene faceting API once it is available - HSEARCH-809. 

> Range facets: .below on numeric null values (AssertionFailure: Unsupported range type)
> --------------------------------------------------------------------------------------
>
>                 Key: HSEARCH-770
>                 URL: http://opensource.atlassian.com/projects/hibernate/browse/HSEARCH-770
>             Project: Hibernate Search
>          Issue Type: Bug
>          Components: query
>    Affects Versions: 3.4.0.Final
>         Environment: Using Hibernate 3.4.0 final, independent on on platform.
>            Reporter: Elmer van Chastelet
>            Assignee: Hardy Ferentschik
>             Fix For: 4.0.0.Alpha1
>
>         Attachments: RangeFacetNumericNullValueFail.zip
>
>
> An assertion failure ("Unsupported range type") is thrown, when getting facets ( facetmanager.getFacets( facetName ) ) after narrowing on a facet ( facetmanager.getFacetGroup( facetingName ).selectFacets( facet )) in the following situation:
> - Using a range facet with _.below_ constraint
> - on a _numeric field_ (i.e. has @NumericField annotation)
> - the field has a _null_ value for at least one indexed entity
> Attached is a unit test that throws this exception.
> My guess is that entities with null values are included in the result of the below facet, so probably null is evaluated to be 'lower' than any valid Integer. The lowest value found is probably used somewhere to set some range during .selectFacets( facetName ). This range is then used again when calling .getFacets( facetingName ), which tries to obtain the type from a null value -> AssertionFailure: Unsupported range type.
> RangeFacetNumericNullValueFail.zip includes a unit test (testRangeBelowWithNullValues() in org.hibernate.search.test.query.facet.RangeFacetingTest) and the modified files which are used by this test (like Truck.java)
> Exception trace:
> {noformat}
> org.hibernate.annotations.common.AssertionFailure: Unsupported range type
>    at org.hibernate.search.query.dsl.impl.RangeFacetImpl.createNumericRangeQuery(RangeFacetImpl.java:146)
>    at org.hibernate.search.query.dsl.impl.RangeFacetImpl.getFacetQuery(RangeFacetImpl.java:55)
>    at org.hibernate.search.query.engine.impl.FacetManagerImpl.createSelectionGroupQuery(FacetManagerImpl.java:160)
>    at org.hibernate.search.query.engine.impl.FacetManagerImpl.getFacetFilter(FacetManagerImpl.java:146)
>    at org.hibernate.search.query.engine.impl.HSQueryImpl.buildFilters(HSQueryImpl.java:650)
>    at org.hibernate.search.query.engine.impl.HSQueryImpl.getQueryHits(HSQueryImpl.java:384)
>    at org.hibernate.search.query.engine.impl.HSQueryImpl.queryDocumentExtractor(HSQueryImpl.java:275)
>    at org.hibernate.search.query.engine.impl.FacetManagerImpl.getFacets(FacetManagerImpl.java:110)
> {noformat}
> See also: [topic in Hibernate user forum|https://forum.hibernate.org/viewtopic.php?f=9&t=1011030]

--
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