# Access number of tokens of a query from a filter

**URL:** <https://discuss.elastic.co/t/access-number-of-tokens-of-a-query-from-a-filter/359869>\
**Category:** Elasticsearch\
**Tags:** painless\
**Created:** [May 20, 2024, 9:12pm UTC](https://discuss.elastic.co/t/access-number-of-tokens-of-a-query-from-a-filter/359869 "2024-05-20T21:12:03Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![antoinelefloch](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/antoinelefloch/32/24577_2.png) [@antoinelefloch](https://discuss.elastic.co/u/antoinelefloch)\
**Post date:** [May 20, 2024, 9:12pm UTC](https://discuss.elastic.co/t/access-number-of-tokens-of-a-query-from-a-filter/359869/1 "2024-05-20T21:12:03Z")

</div>

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.

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

```
