Is there any way elasticsearch ranges key can be converted with scripted values


(Shash) #1

Is there any way elasticsearch ranges key can be converted with scripted values ?
Could some one help me can I achieve similar kind of query from elasticsearch ?

I am trying to do the bucketing with dynamic field values.

{
    "size": 0,
    "_source": false,
    "query": {
        "filtered": {
            "filter": {
                "bool": {
                    "must": {
                        "match_all": {
                            
                        }
                    }
                }
            }
        }
    },
    "aggs": {
        "financialyear": {
            "range": {
                "ranges": [
                    {
                        "key": {
                            "script": "doc['__year_salesDate'].value - 1"
                            
                        },
                        "from": "1",
"to": "3"
                    },
                    {
                        "key": {
                            "script": "doc['__year_salesDate'].value"
                            
                        },
                        "from": "4",
"to": "12"
                    }
                ],
                "field": "__month_salesDate"
            }
        }
    }
}
}

(system) #2

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