# ElasticSearch: What is the param limit in painless scripting?

**URL:** <https://discuss.elastic.co/t/elasticsearch-what-is-the-param-limit-in-painless-scripting/196282>\
**Category:** Elasticsearch\
**Created:** [August 22, 2019, 9:24am UTC](https://discuss.elastic.co/t/elasticsearch-what-is-the-param-limit-in-painless-scripting/196282 "2019-08-22T09:24:55Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![aniruddha.raje](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/aniruddha.raje/32/52148_2.png) [@aniruddha.raje](https://discuss.elastic.co/u/aniruddha.raje)\
**Post date:** [August 22, 2019, 9:24am UTC](https://discuss.elastic.co/t/elasticsearch-what-is-the-param-limit-in-painless-scripting/196282/1 "2019-08-22T09:24:55Z")

</div>

**I will have documents with the following data -**

1. id  
2. user\_id  
3. online\_hr  
4. offline\_hr

**My use case is the following -**  
  
I wish to sort the users who are **active** using `online_hr` field,  
While I want to sort the users who are **inactive** using the `offline_hr` field.

I am planning to use ElasticSearch painless script for this use case,  
I will have using 2 arrays of `online_user_list` and `offline_user_list` into the script params,  
And I plan to compare each document's `user_id`,  
if it is present in the either of the params lists and sort accordingly.

I want to know if there is any limit to the param object,  
As the userbase may be in 100s of thousands,  
And if passing 2 lists of that size in the ES scripting params would be troublesome?  
And if there is any better approach?

**Query to add data -**

```
POST /products/_doc/1
{
  "id":1,
  "user_id" : "1",
  "online_hr" : "1",
  "offline_hr" : "2"
}

```

**Sample data -**

```
{
  "took" : 0,
  "timed_out" : false,
  "_shards" : {
    "total" : 1,
    "successful" : 1,
    "skipped" : 0,
    "failed" : 0
  },
  "hits" : {
    "total" : {
      "value" : 1,
      "relation" : "eq"
    },
    "max_score" : 1.0,
    "hits" : [
      {
        "_index" : "products",
        "_type" : "_doc",
        "_id" : "1",
        "_score" : 1.0,
        "_source" : {
          "id" : 1,
          "user_id" : "1",
          "online_hr" : "1",
          "offline_hr" : "2"
        }
      }
    ]
  }
}

```

**Mapping -**

```
{
  "products" : {
    "aliases" : { },
    "mappings" : {
      "properties" : {
        "id" : {
          "type" : "long"
        },
        "offline_hr" : {
          "type" : "text",
          "fields" : {
            "keyword" : {
              "type" : "keyword",
              "ignore_above" : 256
            }
          }
        },
        "online_hr" : {
          "type" : "text",
          "fields" : {
            "keyword" : {
              "type" : "keyword",
              "ignore_above" : 256
            }
          }
        },
        "user_id" : {
          "type" : "text",
          "fields" : {
            "keyword" : {
              "type" : "keyword",
              "ignore_above" : 256
            }
          }
        }
      }
    },
    "settings" : {
      "index" : {
        "creation_date" : "1566466257331",
        "number_of_shards" : "1",
        "number_of_replicas" : "1",
        "uuid" : "g2F3UlxQSseHRisVinulYQ",
        "version" : {
          "created" : "7020099"
        },
        "provided_name" : "products"
      }
    }
  }
}

```

I found Painless scripts have a default size limit of `65,535 bytes` ,  
while the ElasticSearch compiler had a limit of `16834 characters`

**References -**  
[https://www.elastic.co/guide/en/elasticsearch/painless/current/painless-walkthrough.html](https://www.elastic.co/guide/en/elasticsearch/painless/current/painless-walkthrough.html)  
[https://www.elastic.co/guide/en/elasticsearch/painless/current/painless-sort-context.html](https://www.elastic.co/guide/en/elasticsearch/painless/current/painless-sort-context.html)

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [September 19, 2019, 9:25am UTC](https://discuss.elastic.co/t/elasticsearch-what-is-the-param-limit-in-painless-scripting/196282/2 "2019-09-19T09:25:10Z")

</div>

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