Uploaded image for project: 'PUBLIC - Liferay Portal Community Edition'
  1. PUBLIC - Liferay Portal Community Edition
  2. LPS-114421

Wrong string representation of RangeTermFilter

    Details

      Description

      1. Go to Server Admin > Script
      2. Run
        import com.liferay.portal.kernel.search.filter.RangeTermFilter
        
        RangeTermFilter rangeTermFilter = new RangeTermFilter("modifiedDate", true, true, "20190529", "20200529")
        
        out.println(rangeTermFilter)
        

      Expected :

      {(20190529>=modifiedDate<=20200529), (cached=null, executionOption=null)}
      

      Actual :

      {(20190529>=modifiedDate>=20200529), (cached=null, executionOption=null)}
      

      RangeTermFilter string representation is wrong, as it messed up the Operator textual representation.

      Textual representation shows 

      {MUST({MUST(

      {(202005*01*115959>=modified>=202005*21*015506), (cached=null, executionOption=null)}

      )}, ), MUST_NOT(), SHOULD(), (cached=null, executionOption=null)}

       

      No value of modifed will ever met those conditions.

      The filter works, however. The bug is in the textual representation, and specifically in the Operator.toString() method, that

      ...
      else if (name.equals(LTE.name())) {
       return StringPool.GREATER_THAN_OR_EQUAL;
      }
      ...

      which is obviously wrong.

      The logic of the filter is not affected by this, as later translation to elasticsearch/solr equivalents uses only the bounds and not the operator.

        Attachments

          Activity

            People

            Assignee:
            linda.sui Linda Sui
            Reporter:
            alberto.montero Alberto Montero
            Participants of an Issue:
            Recent user:
            Jason Pince
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:
              Days since last comment:
              33 weeks, 2 days ago

                Packages

                Version Package
                7.2.10 DXP FP6
                7.2.X
                7.3.3 CE GA4
                7.3.10 DXP GA1
                Master