Multiply the field in query result and sort

I am using elasticsearch 2.4 with java transport client. I want to fetch results of a 'field1' after multiplying it with value '0.3', sort it and then fetch first 10 results. I do the following but the multiplication doesn't happen. I rather see the original values of field1.

SearchResponse response = client.prepareSearch(index)
.setQuery(QueryBuilders.matchAllQuery()) // Query
.setQuery(QueryBuilders.scriptQuery(new Script("doc['field1'].value * 0.3", ScriptType.INLINE, "groovy", null)))
.setPostFilter(QueryBuilders.rangeQuery("time").from("now-3d")) // Filter
.addSort("field1", SortOrder.DESC)

Thanks for the help!

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