Global Variable for Script Filter

I'm using the following script filter:

{
  "query": {
    "filtered": {
      "filter": {
        "and": [
          {
            "or": [
              {
                "term": {
                  "states": "co"
                }
              }
            ]
          },
          {
             
        "script" : {
            "script" : "count++; count <= 3",
            "params" : {
                "count" : 0
            }
        }
          }
        ]
      }
      
    }
  }
}

With this query, I'm expecting to get one results back. But since we have 5
shards set up on our ES server, I actually get back 15 results.

Is there a way with a script filter to make the count variable global, or
so that the variable is not reset when searching another shard?

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/a9a3d940-da1e-4e6e-ada5-8e9a7ce9fc4e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.