Access number of tokens of a query from a filter

Hello,

I would like to filter only if there is more than one token in the query. I don't want to filter if there is a single stop word in the query.
I was thinking of using something like here below in my settings, but I just have access to the current token attributes (token.endOffset, token.getTerm().length(), etc)
I would have liked something like query.length() or total number of tokens or total length of the tokens.

Through "token.startOffset", I have a way to know the I am dealing with a token that is not the first, but when I am processing the first one, I don't know if others follow.

Any help would be appreciated.

 "settings": {
   [...]
   "analysis": {
     "filter": {
       "conditional_stop_words" : {
         "filter" : [
           "my_stop_words"
         ],
         "type" : "condition",
         "script" : {
           "source" : "XXXX > 1"
         }
      },
      [...]
    }
 }