Uploaded image for project: 'Hibernate Search'
  1. HSEARCH-1346

Selected Facet object not equal to computed Facet object

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 4.3.0.CR1
    • Fix Version/s: 4.3.0.Final
    • Component/s: query
    • Labels:
      None
    • Bug Testcase Reminder (view):

      Bug reports should generally be accompanied by a test case!

      Description

      The following pseudo code scenario is expected to work but fails

      //create some facet requests
      //enable the facet requests
      
      //select by facet1
      Facet facet1 = facetManager.getFacets( facetGroupName1 ).get( 0 );
      facetManager.getFacetGroup( facetGroupName1 ).selectFacets( facet1 );
      
      Facet facet2 = facetManager.getFacets( facetGroupName2 ).get( 0 );
      //select by facet2 that reduces facet1 count
      facetManager.getFacetGroup( facetGroupName2 ).selectFacets( facet2 );
      
      List<Facet> recomputedFacets = facetManager.getFacets( facetGroupName1 );
      Facet almostFacet1 = facetManager.getFacets( facetGroupName1 ).get(0);
      // Following test fails
      assertTrue( facetManager.getFacetGroup( facetGroupName1 ).contains( almostFacet1 ) ); 
      

      This is due to the fact that facet objects are different (between selected ones and recomputed ones) and that equals takes the count into account.

      There are two possible fixes:
      1. replace selectedFacet with recomputed ones
      2. not take count as part of Facet's equality

      I think 1. would be impractical especially since Facet reference can float around. So removing count from the equality seems best. However I don't fully understand why Facet.count was part of it in the first place

        Attachments

          Activity

            People

            • Assignee:
              emmanuel Emmanuel Bernard
              Reporter:
              emmanuel Emmanuel Bernard
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: