How to create Java query for a script

(Santosh Pandey) #1

I have 2 attributes: price1 and price2.
I need to filter the result if price1 < price2

How to create Java code for it. I have written the following:
QueryBuilders.boolQuery()
.filter(QueryBuilders.scriptQuery("doc['lowestOurPrice'].value < doc['lowestBasePrice'].value"));

scriptQuery accepts Script object. How to create Script object with my query?