{"action":"created","issue":{"url":"https://api.github.com/repos/elastic/elasticsearch/issues/11160","labels_url":"https://api.github.com/repos/elastic/elasticsearch/issues/11160/labels{/name}","comments_url":"https://api.github.com/repos/elastic/elasticsearch/issues/11160/comments","events_url":"https://api.github.com/repos/elastic/elasticsearch/issues/11160/events","html_url":"https://github.com/elastic/elasticsearch/issues/11160","id":76205845,"number":11160,"title":"Partial_fields should not reorder document properties","user":{"login":"abibell","id":544653,"avatar_url":"https://avatars.githubusercontent.com/u/544653?v=3","gravatar_id":"","url":"https://api.github.com/users/abibell","html_url":"https://github.com/abibell","followers_url":"https://api.github.com/users/abibell/followers","following_url":"https://api.github.com/users/abibell/following{/other_user}","gists_url":"https://api.github.com/users/abibell/gists{/gist_id}","starred_url":"https://api.github.com/users/abibell/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/abibell/subscriptions","organizations_url":"https://api.github.com/users/abibell/orgs","repos_url":"https://api.github.com/users/abibell/repos","events_url":"https://api.github.com/users/abibell/events{/privacy}","received_events_url":"https://api.github.com/users/abibell/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":4,"created_at":"2015-05-14T02:45:11Z","updated_at":"2015-05-18T16:44:34Z","closed_at":"2015-05-15T18:23:22Z","body":"When using partial fields the document's properties are reordered, we don't want that.\r\n# Steps to replicate\r\n1. Suppose I stored document schema is\r\n```javascript\r\n{ \"first\": \"abcd\", \"second\": \"xyz\"}\r\n```\r\n\r\n```javascript\r\nPOST _search\r\n{\r\n   \"partial_fields\" : {\r\n        \"_source\" : {\r\n            \"exclude\" : \"field1\"\r\n        }\r\n    }\r\n}\r\n```\r\n# Expected\r\nDocument with property order is preserved same as they were stored after excluding or including properties as per query\r\n```javascript\r\n{ \"first\": \"abcd\", \"second\": \"xyz\"}\r\n```\r\n\r\n# Actual\r\nDocument properties are jumbled\r\n```javascript\r\n{ \"second\": \"xyz\", \"first\": \"abcd\" }\r\n```\r\n\r\n# Notes\r\nWe use document like this:\r\n```javascript\r\n{\r\n               \"header\": {\r\n                  \"identifier\": \"oai:nla.gov.au:nla.map-edlc1-10\",\r\n                  \"datestamp\": \"2012-11-26T04:17:25Z\",\r\n                  \"setSpec\": \"Map\",\r\n                  \"status\": null\r\n               },\r\n               \"title\": \"Some title\",\r\n               \"creator\": [\r\n                  \"Sally Smith\"\r\n               ],\r\n               \"subject\": [\r\n                  \"Geological\",\r\n                  \"Geological cross sections -- France\",\r\n                  \"Charts\"\r\n               ],\r\n               \"description\": \"Section in Noeux\",\r\n               \"publisher\": [\r\n                  \"1920\"\r\n               ],\r\n               \"contributor\": [\r\n                  \"John Smith\",\r\n                  \"Sally Smith\"\r\n               ],\r\n               \"date\": \"1977-01-01\",\r\n               \"type\": [\r\n                  \"Image\"\r\n               ],\r\n               \"format\": \"2 ms. sections on 1 sheet : col. ; sheet 41.8 x 34.3 cm.\",\r\n               \"identifier\": \"http://nla.gov.au/nla.map-edlc11-10\",\r\n               \"source\": \"Item held by National Library of Australia\",\r\n               \"language\": [\"English\"],\r\n               \"relation\": \"Part of: [Collection of Edgeworth David's maps] [cartographic material].\",\r\n               \"coverage\": \"1977-01-01\"\r\n            }\r\n         }\r\n```"},"comment":{"url":"https://api.github.com/repos/elastic/elasticsearch/issues/comments/103122824","html_url":"https://github.com/elastic/elasticsearch/issues/11160#issuecomment-103122824","issue_url":"https://api.github.com/repos/elastic/elasticsearch/issues/11160","id":103122824,"user":{"login":"abibell","id":544653,"avatar_url":"https://avatars.githubusercontent.com/u/544653?v=3","gravatar_id":"","url":"https://api.github.com/users/abibell","html_url":"https://github.com/abibell","followers_url":"https://api.github.com/users/abibell/followers","following_url":"https://api.github.com/users/abibell/following{/other_user}","gists_url":"https://api.github.com/users/abibell/gists{/gist_id}","starred_url":"https://api.github.com/users/abibell/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/abibell/subscriptions","organizations_url":"https://api.github.com/users/abibell/orgs","repos_url":"https://api.github.com/users/abibell/repos","events_url":"https://api.github.com/users/abibell/events{/privacy}","received_events_url":"https://api.github.com/users/abibell/received_events","type":"User","site_admin":false},"created_at":"2015-05-18T16:44:34Z","updated_at":"2015-05-18T16:44:34Z","body":"I don't want this to be a \"who is technically competent match\". We can\nsimply provide facts invalidating each other, continue to say wrong source,\nunrelated, wrong interpretation and maybe wonder why the other person is\nnot able to see the point. I don't take everything that is written as\nTruth. To me technology is born to solve problems and not to be a\nbottleneck.\n\nAll I am saying is JSON structure was preserved in all languages I have\nused. It will make our lives better if we addressed the order. There is no\nissue if we preserve the order. Random Hashing issue you mentioned is only\nimplemented by 3/3000+ languages and only recently. Plus randomised hashing\nis not going to make any difference to the order preservation. If we\nrepeatedly serialize and deserialize the hash will change, which is wrong\nbecause it is same object. It's not the problem of randomised hashing. It\nis serializing processes.\nOn 18/05/2015 9:36 pm, \"Clinton Gormley\" <notifications@github.com> wrote:\n\n> JSON definition doesn't say it is *unstructured according to Wikipedia or\n> the RFC specification. Regardless of what it says. Why not make it better?\n> Standard says json can be serialized and validated using xsd. If json was\n> unstructured it would have failed.\n>\n> The spec at http://json.org/ says:\n>\n> An object is an unordered set of name/value pairs.\n>\n> The Wikipedia article at\n> http://en.wikipedia.org/wiki/JSON#Data_types.2C_syntax_and_example says:\n>\n> Object — an unordered collection of name/value pairs where the names (also\n> called keys) are strings.\n>\n> Most languages use hash randomization to avoid hash collision attacks (see\n> http://lemire.me/blog/archives/2012/01/17/use-random-hashing-if-you-care-about-security/\n> ) so it is quite likely that deserealizing then reserealizing a JSON object\n> will result in a different key order. This is by design.\n>\n> Also see http://stackoverflow.com/a/4515863/819598 about why you\n> shouldn't depend on order.\n>\n> —\n> Reply to this email directly or view it on GitHub\n> <https://github.com/elastic/elasticsearch/issues/11160#issuecomment-103025964>\n> .\n>\n"}}