{"action":"opened","issue":{"url":"https://api.github.com/repos/elastic/elasticsearch/issues/13822","labels_url":"https://api.github.com/repos/elastic/elasticsearch/issues/13822/labels{/name}","comments_url":"https://api.github.com/repos/elastic/elasticsearch/issues/13822/comments","events_url":"https://api.github.com/repos/elastic/elasticsearch/issues/13822/events","html_url":"https://github.com/elastic/elasticsearch/issues/13822","id":108586009,"number":13822,"title":"sum aggregation got wrong answer","user":{"login":"caipeichao","id":1661871,"avatar_url":"https://avatars.githubusercontent.com/u/1661871?v=3","gravatar_id":"","url":"https://api.github.com/users/caipeichao","html_url":"https://github.com/caipeichao","followers_url":"https://api.github.com/users/caipeichao/followers","following_url":"https://api.github.com/users/caipeichao/following{/other_user}","gists_url":"https://api.github.com/users/caipeichao/gists{/gist_id}","starred_url":"https://api.github.com/users/caipeichao/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/caipeichao/subscriptions","organizations_url":"https://api.github.com/users/caipeichao/orgs","repos_url":"https://api.github.com/users/caipeichao/repos","events_url":"https://api.github.com/users/caipeichao/events{/privacy}","received_events_url":"https://api.github.com/users/caipeichao/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2015-09-28T04:04:38Z","updated_at":"2015-09-28T04:04:38Z","closed_at":null,"body":"I'm using `1.3.4`. Java version `1.7.0_71-b14`.\r\nSum aggregation goes wrong in my production environment.\r\n\r\nThe mapping is:\r\n\r\n``` json\r\n{\r\n  \"activity\": {\r\n    \"date_detection\": false,\r\n    \"properties\": {\r\n      \"partnerCode\": {\r\n        \"type\": \"string\",\r\n        \"fields\": {\r\n          \"raw\": {\r\n            \"type\": \"string\",\r\n            \"index\": \"not_analyzed\"\r\n          }\r\n        }\r\n      }\r\n      \"payAmount\": {\r\n        \"type\": \"long\"\r\n      }\r\n    },\r\n    ...\r\n  }\r\n  ...\r\n}\r\n```\r\n\r\nWhen I send a aggregation query:\r\n\r\n``` json\r\n{\r\n        \"query\":{\r\n                \"filtered\":{\r\n                        \"filter\":{\r\n                                \"bool\":{\r\n                                        \"must\":[\r\n                                                {\"term\": {\"activity.partnerCode.raw\":\"xxx\"}}\r\n                                        ]\r\n                                }\r\n                        }\r\n                }\r\n        },\r\n        \"aggs\": {\r\n                \"a\": {\r\n                        \"sum\": {\r\n                                \"field\": \"activity.payAmount\"\r\n                        }\r\n                }\r\n        },\r\n        \"size\": 0\r\n}\r\n```\r\n\r\nI got the response:\r\n\r\n``` json\r\n{\r\n    \"took\":9562,\r\n    \"timed_out\":false,\r\n    \"_shards\":{\"total\":2,\"successful\":2,\"failed\":0},\r\n    \"hits\":{\"total\":1911,\"max_score\":0.0,\"hits\":[]},\r\n    \"aggregations\":{\r\n        \"a\":{\"value\":5.083666008154969E20}\r\n    }\r\n}\r\n```\r\n\r\nThe `payAmount` stores how much money was spend in a trade. No customer had that much money.\r\n\r\nI use scan&scroll to export documents, and sum `payAmount' getting 15094439.\r\n\r\nIt seems index is corrupted and I don't know how to fix it."}}