How to retrieve sum from elasticSearch using java

Hello,
I am having 5 fileds (viz. A,B,C & D) in my index.
I want to retrieve sum of field B for my query using java.
Can any1 explain me to do so ?
I've gone through Elastic Docs about aggregation, but did not understand how to use it in java code

Are you able to do it from the Kibana dev console? Without Java I meant but just by using the API?

If so, could you share the query?
If not, start by writing it without Java just using the API. Then translating to Java is pretty much obvious.

And we can help from this script.

I want to write in java using elastic API, but I'm unable to understand how to use those Aggregation (SUM) in java

Here is the documentation:

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