Creating script field using groovy - substring

Hi, i want to extract the part of String field.

that is,
i want to classify paths : (A/B/C, A/B/D, A/B/E), (F/G/H), (F/I/A).
but kibana classify (A/B/C), (A/B/D), (A/B/E), (F/G/H), (F/I/A) understandably..

so i have to use script in elasticsearch. (because kibana doesn't support non-numeric)
first of all i queried this :
curl -XGET 'localhost:9200/myaccess/_search?pretty' -d '
"query" : {
"filtered" : {
"filter" : {
"script" : {
"script" : "doc['path'].value.substring(0,10)",
"lang" : "groovy"

and i got this error :
Caused by: ScriptException[failed to run inline script [doc[path].value.substring(0,5)] using lang [groovy]]; nested: MissingPropertyException[No such property: path for class: a72297f9c561c49dd73726e45411b0217a86e7db];

and 'path' field exist in myaccess index.

is any problem in query? why this error occured?