Your request looks good. Did you maybe mis-type the field name for the sum aggregation?
On Wed, Apr 1, 2015 at 5:06 PM, Muddadi Hemaanusha < [email protected]> wrote: > Hi Team, > > I would like to get the exact result of an SQL query > > select sum(Amount) from Emp group by (Name).... Here If I take an example > like > > id Name amount > 1 A1 100 > 2 A2 200 > 3 A3 300 > 4 A1 200 > 5 A2 300 > > So for the above query the result will be Sum(Amount) by grouping the > names A1, A2, A3 and for A1--> sum(100+200=300), A2-->sum(200+300=500), > A3-->sum(300)... > > For this query I have used the following equivalent query using > Aggregations as shown below: > > GET ABCD/_search > { > "size": 0, > > "aggs": { > "group_trans": { > "terms": { > "field": "trans" > }, > "aggs": { > "sum_ordamt":{ > "sum":{ > "field":"ordamt" > } > } > } > } > } > } > > Am getting the result as: > > "aggregations": { > "group_trans": { > "doc_count_error_upper_bound": 81, > "sum_other_doc_count": 1371988, > "buckets": [ > { > "key": "7ce2d738-5549-4da2-aed0-db939f3a9188", > "doc_count": 282, > "sum_ordamt": { > "value": 0 > } > }, > { > "key": "8f4b187a-f321-4d25-bbc0-a9e78f5810b8", > "doc_count": 230, > "sum_ordamt": { > "value": 0 > } > }, > { > "key": "ca54db4c-620b-4650-bef6-350e83a0ca2c", > "doc_count": 170, > "sum_ordamt": { > "value": 0 > } > } > . > . > . > ] > } > } > } .........................Here Am getting sum > value==0, May I know is there any way to Make a query relevant to the SQL > query given above for to give the sum depending on the group by names... > > -- > You received this message because you are subscribed to the Google Groups > "elasticsearch" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > To view this discussion on the web visit > https://groups.google.com/d/msgid/elasticsearch/ab20bcf5-d573-431b-bb9e-7c1207109988%40googlegroups.com > <https://groups.google.com/d/msgid/elasticsearch/ab20bcf5-d573-431b-bb9e-7c1207109988%40googlegroups.com?utm_medium=email&utm_source=footer> > . > For more options, visit https://groups.google.com/d/optout. > -- Adrien -- You received this message because you are subscribed to the Google Groups "elasticsearch" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/CAO5%3DkAhu6roECh%2BkkPROFqYWNoD6B_nvn-79AEGDD6-FwcvAtA%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.
