Hi,
I want to use substr function for my field 'AlimTarihi'
for example ALimTarihi = 2009-01-02
I want to take onlly ALimTarihi = 2009
My codes:
GET titubb56k/ihale/_search
{
"size":0,
"query":{
"match": {
"UrunNo": "+1782608550161J"
}
},
"aggs": {
"IstekliKoduCount": { "terms":{ "field": "IstekliKodu"}},
"TarihCount": { "terms":{ "field": "AlimTarihi"}},
"ToplamTutarSum": {"sum": {"field": "ToplamTutar"}},
"my_terms": {"terms": {"script" : {"inline": "doc['AlimTarihi'].value.substring(0,2)"}}}
}
}
error:
{
"took": 6,
"timed_out": false,
"_shards": {
"total": 5,
"successful": 3,
"failed": 2,
"failures": [
{
"shard": 1,
"index": "titubb56k",
"node": "NchqMHFlRZqnHALL4pRzUA",
"reason": {
"type": "script_exception",
"reason": "runtime error",
"caused_by": {
"type": "illegal_argument_exception",
"reason": "Unable to find dynamic method [substring] with [2] arguments for class [java.lang.Long]."
},
"script_stack": [
"doc['AlimTarihi'].value.substring(0,4)",
" ^---- HERE"
],
"script": "doc['AlimTarihi'].value.substring(0,4)",
"lang": "painless"
}
}
]
},
"hits": {
"total": 0,
"max_score": 0,
"hits": []
},
"aggregations": {
"ToplamTutarSum": {
"value": 0
},
"IstekliKoduCount": {
"doc_count_error_upper_bound": 0,
"sum_other_doc_count": 0,
"buckets": []
},
"my_terms": {
"doc_count_error_upper_bound": 0,
"sum_other_doc_count": 0,
"buckets": []
},
"TarihCount": {
"doc_count_error_upper_bound": 0,
"sum_other_doc_count": 0,
"buckets": []
}
}
}
What can I do?