# Elasticsearch painless split

**URL:** <https://discuss.elastic.co/t/elasticsearch-painless-split/134515>\
**Category:** Elasticsearch\
**Created:** [June 5, 2018, 3:23am UTC](https://discuss.elastic.co/t/elasticsearch-painless-split/134515 "2018-06-05T03:23:27Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![hubiao](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/hubiao/32/26178_2.png) [@hubiao](https://discuss.elastic.co/u/hubiao)\
**Post date:** [June 5, 2018, 3:23am UTC](https://discuss.elastic.co/t/elasticsearch-painless-split/134515/1 "2018-06-05T03:23:27Z")

</div>

Environmental Science  
elasticsearch 5.5  
JDK 1.8  
windows 7

Why does split make a mistake?

```
GET /data/_search
    {
      "from": 0,
      "size": 6,
      "query": {
         "function_score": {
             "query": {
        "bool": {
          "must": [
            {
              "term": {
                "bookId_no_analyzer_sore": "0788e462-21a1-4c31-91ce-7e0383310a1a"
              }
            }
          ]
        }},
            "script_score" : {
                "script" : {
                    "lang": "painless",
                  "params": {
                    "a": "行动"
                  },
                  "inline": "def myText = doc['text_nlp_sore.keyword'].value;if(myText != null){return myText.split(params.a).length;}else{return -1;}"
                }
            }
        }
      },
      
      "sort": [
        {
          "_score": {
            "order": "desc"
          }
        },
        {
          "pageNo_int_sore": {
            "order": "asc"
          }
        }
      ]
    }

```

out error

```
{
   "error": {
      "root_cause": [
         {
            "type": "script_exception",
            "reason": "runtime error",
            "script_stack": [
               "return myText.split(params.a).length;}else{",
               " ^---- HERE"
            ],
            "script": "def myText = doc['text_nlp_sore.keyword'].value;if(myText != null){return myText.split(params.a).length;}else{return -1;}",
            "lang": "painless"
         }
      ],
      "type": "search_phase_execution_exception",
      "reason": "all shards failed",
      "phase": "query",
      "grouped": true,
      "failed_shards": [
         {
            "shard": 0,
            "index": "data",
            "node": "Gmil1PRGR4KJ2EXW1vV2hg",
            "reason": {
               "type": "script_exception",
               "reason": "runtime error",
               "script_stack": [
                  "return myText.split(params.a).length;}else{",
                  " ^---- HERE"
               ],
               "script": "def myText = doc['text_nlp_sore.keyword'].value;if(myText != null){return myText.split(params.a).length;}else{return -1;}",
               "lang": "painless",
               "caused_by": {
                  "type": "illegal_argument_exception",
                  "reason": "Unable to find dynamic method [split] with [1] arguments for class [java.lang.String]."
               }
            }
         }
      ]
   },
   "status": 500
}
```

---

<div class="post-metadata">

**Author:** ![hubiao](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/hubiao/32/26178_2.png) [@hubiao](https://discuss.elastic.co/u/hubiao)\
**Post date:** [June 5, 2018, 6:31am UTC](https://discuss.elastic.co/t/elasticsearch-painless-split/134515/2 "2018-06-05T06:31:14Z")

</div>

Anybody here?

---

<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:** [July 3, 2018, 6:31am UTC](https://discuss.elastic.co/t/elasticsearch-painless-split/134515/3 "2018-07-03T06:31:15Z")

</div>

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