Optimization of function_score's functions clause to adjust scores for a range of specific fields

Hi everyone,

I want to adjust the score according to the range of a particular field in function_score.
For example, I have the following query in mind.

{
   "query":{
      "function_score":{
         "query": {  ....hogehoge }
      },
      "functions":[
         {
            "filter":{
               "range":{
                  "lastLogin":{
                     "lte":"2022-05-29T06:58:53.652Z"
                  }
               }
            },
            "weight":1
         },
         {
            "filter":{
               "range":{
                  "lastLogin":{
                     "gte":"2022-05-29T06:58:53.652Z",
                     "lte":"2022-05-30T06:58:53.652Z"
                  }
               }
            },
            "weight":2
         },
         {
            "filter":{
               "range":{
                  "lastLogin":{
                     "gte":"2022-05-30T06:58:53.652Z",
                     "lte":"2022-05-31T06:58:53.652Z"
                  }
               }
            },
            "weight":3
         },
         ..... and more
      ],
      "score_mode":"sum"
   }
}

However, I'm afraid this writing style is not performing well
Is there any efficient way to write it?
The version of ES used is 6.8.12

Thank you.

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.