JSON with script and aggregation Query to Java REST High or Low Level Client

Hi all,
I'm querying ES 7.3 from the Java REST High Level Client.
For "simple" queries, I have always been able to transcript them to Java, but this time, I face the problem.
This is the JSON query

{
    "query": {
        "bool": {
            "filter": {
                "script": {
                    "script": {
                        "source": "(doc['mois'].value.getYear()==2019) && (doc['mois'].value.getMonthValue()==4)",
                        "lang": "painless"
                    }
                }
            },
            "must": {
                "bool": {
                    "should": [
                        {"term" : {"numid": 51237}},
                        {"term" : {"numid": 13798}},
                        {"term" : {"numid": 10764}},
                        {"term" : {"numid": 12909}},
                        {"term" : {"numid": 12445}},
                        {"term" : {"numid": 12946}},
                        {"term" : {"numid": 13007}}                     
                    ]
                }
            }
            
        }
    },
    "aggs": {
        "sum_download": {
            "sum": {
                "script": {
                    "source": "doc['download']"
                }
            }
        },
        "sum_upload": {
            "sum": {
                "script": {
                    "source": "doc['upload']"
                }
            }
        }
    }
}

The bool / must / should queries are what I'm able to transcript to Java.
But the script / aggs ones... are harder.

Have you got any kind of tutorial for that use case of transcripting this to Java REST High or Low Level Client?

Thank you.

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