Search template condition on paramters

Hello Everybody, Happy new year 2022.

I have a small use case that i want to implement using Elasticsearch search template
The idea is to limit the parameter from so that it can't go more that a limit value.

Do you have any idea on how to force the parameter from to not to go more than the value of max parameter ?

The search template would be something like this, i wasn't able to find a way to implement this kind of condition

if params.from > params.max then params.max else params.from

POST _render/template
{
  "source": {
    "query": {
      "match": {
        "message": "{{query_string}}"
      }
    },
    "from": "{{from}}{{^from}}0{{/from}}",
    "size": "{{size}}{{^size}}10{{/size}}"
  },
  "params": {
    "query_string": "hello world",
    "from": 0,
    "size": 15,
    "max": 25
  }
}

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