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