How to perform with condition divide math operation in elasticsearch

I have a query like this
how I perform a query in Elasticsearch with this condition
if wager == 0 : payout/1 >= multiplier
else: payout/wager >= multiplier
filter multiplier according to this condition
I wrote this query but it's not working

"query": {
            "bool": {
                "filter": [
                    {
                        "script": {
                            "script": {
                                "params": {
                                    "multiplier": "1"
                                },
                                "source": "if (doc['wager_usd'].value == 0) {return doc['payout_usd'].value / 1 >= params.multiplier;}return doc['payout_usd'].value / doc['wager_usd'].value >= params.multiplier;"
                            }
                        }
                    }
                ]
            }
        }

what I have wrong with this query, please help me!
Thanks!

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