{"action":"created","issue":{"url":"https://api.github.com/repos/elastic/elasticsearch-py/issues/855","repository_url":"https://api.github.com/repos/elastic/elasticsearch-py","labels_url":"https://api.github.com/repos/elastic/elasticsearch-py/issues/855/labels{/name}","comments_url":"https://api.github.com/repos/elastic/elasticsearch-py/issues/855/comments","events_url":"https://api.github.com/repos/elastic/elasticsearch-py/issues/855/events","html_url":"https://github.com/elastic/elasticsearch-py/issues/855","id":369353287,"node_id":"MDU6SXNzdWUzNjkzNTMyODc=","number":855,"title":"Add option to `bulk` indexer to automatically add nested mapping where appropriate","user":{"login":"melissachang","id":10929390,"node_id":"MDQ6VXNlcjEwOTI5Mzkw","avatar_url":"https://avatars1.githubusercontent.com/u/10929390?v=4","gravatar_id":"","url":"https://api.github.com/users/melissachang","html_url":"https://github.com/melissachang","followers_url":"https://api.github.com/users/melissachang/followers","following_url":"https://api.github.com/users/melissachang/following{/other_user}","gists_url":"https://api.github.com/users/melissachang/gists{/gist_id}","starred_url":"https://api.github.com/users/melissachang/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/melissachang/subscriptions","organizations_url":"https://api.github.com/users/melissachang/orgs","repos_url":"https://api.github.com/users/melissachang/repos","events_url":"https://api.github.com/users/melissachang/events{/privacy}","received_events_url":"https://api.github.com/users/melissachang/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-10-12T00:18:35Z","updated_at":"2019-02-28T16:22:56Z","closed_at":null,"author_association":"NONE","body":"I am using `bulk` to index this JSON dict:\r\n```\r\n{  \r\n   \"project.nested.repeated.addresses\":[  \r\n      {  \r\n         \"status\":\"current\",\r\n         \"city\":\"New York\",\r\n         \"zip\":33333,\r\n         \"state\":\"NY\",\r\n         \"address\":\"789 Any Avenue\",\r\n         \"numberOfYears\":2\r\n      },\r\n      {  \r\n         \"status\":\"previous\",\r\n         \"city\":\"Hoboken\",\r\n         \"zip\":44444,\r\n         \"state\":\"NJ\",\r\n         \"address\":\"321 Main Street\",\r\n         \"numberOfYears\":3\r\n      }\r\n   ],\r\n   \"project.nested.repeated.first_name\":\"Jane\",\r\n   \"project.nested.repeated.last_name\":\"Doe\"\r\n}\r\n```\r\n\r\nI would like the addresses field to be [nested in the Elasticsearch sense](https://www.elastic.co/guide/en/elasticsearch/reference/current/nested.html).\r\n\r\nI have code that [manually crawls the schema and adds nested mappings](https://github.com/DataBiosphere/data-explorer-indexers/blob/e0aace1c166aa9c7eb97e87d8ed791f0d5630fb8/bigquery/indexer.py#L96).\r\n\r\nIt would be nice if I didn't have to manually put `nested` everywhere. This seems like a common use case:\r\n\r\nIf there is a nested JSON field, make the corresponding Elasticsearch field nested."},"comment":{"url":"https://api.github.com/repos/elastic/elasticsearch-py/issues/comments/468336883","html_url":"https://github.com/elastic/elasticsearch-py/issues/855#issuecomment-468336883","issue_url":"https://api.github.com/repos/elastic/elasticsearch-py/issues/855","id":468336883,"node_id":"MDEyOklzc3VlQ29tbWVudDQ2ODMzNjg4Mw==","user":{"login":"GlenRSmith","id":1327920,"node_id":"MDQ6VXNlcjEzMjc5MjA=","avatar_url":"https://avatars3.githubusercontent.com/u/1327920?v=4","gravatar_id":"","url":"https://api.github.com/users/GlenRSmith","html_url":"https://github.com/GlenRSmith","followers_url":"https://api.github.com/users/GlenRSmith/followers","following_url":"https://api.github.com/users/GlenRSmith/following{/other_user}","gists_url":"https://api.github.com/users/GlenRSmith/gists{/gist_id}","starred_url":"https://api.github.com/users/GlenRSmith/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/GlenRSmith/subscriptions","organizations_url":"https://api.github.com/users/GlenRSmith/orgs","repos_url":"https://api.github.com/users/GlenRSmith/repos","events_url":"https://api.github.com/users/GlenRSmith/events{/privacy}","received_events_url":"https://api.github.com/users/GlenRSmith/received_events","type":"User","site_admin":false},"created_at":"2019-02-28T16:22:56Z","updated_at":"2019-02-28T16:22:56Z","author_association":"CONTRIBUTOR","body":"@melissachang As there are significant performance consequences of making this choice, all users would not want to have it forced on them. Put another way, the core product exposes the option to the user to use nested or not use nested. For a low-level language client to remove that choice would be peculiar.\r\nThis client tries to remain as faithful as possible to the behavior of Elasticsearch, so it exposes the choice in the same way. If mapping an inner object field as `nested` is desirable, the user can explicitly state that in a mapping command. Otherwise, the default is not nested. Flipping that behavior specifically for users of a specific language client would be \"astonishing\"; that is, suddenly they get this quirky behavior they don't get from Elasticsearch.\r\nFor your specific situation, you might wish to explore index templates, including dynamic (field mapping) templates. Basically, you could put in your cluster rules that say \"if you encounter an object field, map it as nested\".\r\n\r\n"}}
{"actor":{"display_login":"GlenRSmith"}}