How get sum for example with integer fields of each doc

I use elastic with spring boot ,and have integer fields in my doc and now I need to do some calculation with those fields for each doc ,is that possible??

this is some try

Script script = new Script("{\n" +
            "  \"script_fields\": {\n" +
            "    \"my_doubled_field\": {\n" +
            "      \"script\": {\n" +
            "        \"lang\":   \"expression\",\n" +
            "        \"source\": \"doc['salary'] * multiplier\",\n" +
            "        \"params\": {\n" +
            "          \"multiplier\": 2\n" +
            "        }\n" +
            "      }\n" +
            "    }\n" +
            "  }\n" +
            "}");

    QueryBuilder queryBuilder1= QueryBuilders
            .scriptQuery(script);
    Query query= new NativeSearchQueryBuilder()
            .withQuery(queryBuilder1)
            .build();

    SearchHits<Stories>
            searchHits = elasticsearchOperations.search(query, Stories.class
            , IndexCoordinates.of("products"));

but doesn't work

Are you asking how to do this with Enterprise Search, or Elasticsearch?

I'm asking how to do this in spring boot

hi @warkolm I integrated elastic with spring boot and now need to do that is that possible?

I am not sure, but you asked in Workplace Search, which is not the right category. I will move this.

okay @warkolm thanks