{"action":"created","issue":{"url":"https://api.github.com/repos/elastic/elasticsearch/issues/11830","repository_url":"https://api.github.com/repos/elastic/elasticsearch","labels_url":"https://api.github.com/repos/elastic/elasticsearch/issues/11830/labels{/name}","comments_url":"https://api.github.com/repos/elastic/elasticsearch/issues/11830/comments","events_url":"https://api.github.com/repos/elastic/elasticsearch/issues/11830/events","html_url":"https://github.com/elastic/elasticsearch/issues/11830","id":90414493,"number":11830,"title":"[DOC] Multi-level nested query syntax, add more clarity in docs.","user":{"login":"RanadeepPolavarapu","id":7084995,"avatar_url":"https://avatars1.githubusercontent.com/u/7084995?v=4","gravatar_id":"","url":"https://api.github.com/users/RanadeepPolavarapu","html_url":"https://github.com/RanadeepPolavarapu","followers_url":"https://api.github.com/users/RanadeepPolavarapu/followers","following_url":"https://api.github.com/users/RanadeepPolavarapu/following{/other_user}","gists_url":"https://api.github.com/users/RanadeepPolavarapu/gists{/gist_id}","starred_url":"https://api.github.com/users/RanadeepPolavarapu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/RanadeepPolavarapu/subscriptions","organizations_url":"https://api.github.com/users/RanadeepPolavarapu/orgs","repos_url":"https://api.github.com/users/RanadeepPolavarapu/repos","events_url":"https://api.github.com/users/RanadeepPolavarapu/events{/privacy}","received_events_url":"https://api.github.com/users/RanadeepPolavarapu/received_events","type":"User","site_admin":false},"labels":[{"id":146832564,"url":"https://api.github.com/repos/elastic/elasticsearch/labels/:Search/Search","name":":Search/Search","color":"0e8a16","default":false},{"id":23715,"url":"https://api.github.com/repos/elastic/elasticsearch/labels/%3Edocs","name":">docs","color":"db755e","default":false},{"id":110815527,"url":"https://api.github.com/repos/elastic/elasticsearch/labels/adoptme","name":"adoptme","color":"207de5","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":13,"created_at":"2015-06-23T15:11:00Z","updated_at":"2018-03-02T05:21:29Z","closed_at":null,"author_association":"NONE","body":"Nested query on one level is working great, but after the second level onwards (nesting) the query returns no results.\n\nHere is my example:\n\n```\n{\n    \"mappings\": {\n        \"customers\": {\n            \"properties\": {\n                \"lastUpdated\": {\n                    \"type\": \"long\"\n                },\n                \"isDeleted\": {\n                    \"type\": \"boolean\"\n                },\n                \"person\": {\n                    \"type\": \"nested\",\n                    \"properties\": {\n                        \"car\": {\n                            \"type\": \"nested\",\n                            \"properties\": {\n                                \"model\": {\n                                    \"type\": \"string\"\n                                },\n                                \"make\": {\n                                    \"type\": \"string\"\n                                }\n                            }\n                        },\n                        \"last_name\": {\n                            \"type\": \"string\"\n                        },\n                        \"first_name\": {\n                            \"type\": \"string\"\n                        }\n                    }\n                }\n            }\n        }\n    }\n}\n```\n\nMy documents:\n\n```\n{\n    \"person\": {\n        \"first_name\": \"Zach\",\n        \"last_name\": \"Foobar\",\n        \"car\": [\n            {\n                \"make\": \"Saturn\",\n                \"model\": \"SL\"\n            },\n            {\n                \"make\": \"Subaru\",\n                \"model\": \"Imprezza\"\n            }\n        ]\n    },\n    \"isDeleted\": false,\n    \"lastUpdated\": 1433257051959\n}\n\n{\n    \"person\": {\n        \"first_name\": \"Bob\",\n        \"last_name\": \"Doe\",\n        \"car\": [\n            {\n                \"make\": \"Saturn\",\n                \"model\": \"Imprezza\"\n            },\n            {\n                \"make\": \"Honda\",\n                \"model\": \"Accord\"\n            }\n        ]\n    },\n    \"isDeleted\": false,\n    \"lastUpdated\": 1433257051959\n}\n```\n\nLastly, my query and result:\n\n```\n{\n    \"query\": {\n        \"nested\": {\n            \"path\": \"person\",\n            \"query\": {\n                \"match\": {\n                    \"person.car.make\": \"Honda\"\n                }\n            },\n            \"inner_hits\": {}\n        }\n    }\n}\n\n{\n  \"took\": 1,\n  \"timed_out\": false,\n  \"_shards\": {\n    \"total\": 5,\n    \"successful\": 5,\n    \"failed\": 0\n  },\n  \"hits\": {\n    \"total\": 0,\n    \"max_score\": null,\n    \"hits\": []\n  }\n}\n```\n\n---\n\nEDIT: So, It seems that this query works, but not the one above. \n\n```\n{\n    \"query\": {\n        \"nested\": {\n            \"path\": \"person\",\n            \"query\": {\n                \"match\": {\n                    \"person.car.make\": \"Honda\"\n                }\n            },\n            \"inner_hits\": {}\n        }\n    }\n}\n```\n\nI would suggest adding more clarity in the docs for multi-level nested queries about the path and query path. The [doc](https://www.elastic.co/guide/en/elasticsearch/guide/current/nested-query.html)  for nested query should be enhance for multi-level nesting.\n"},"comment":{"url":"https://api.github.com/repos/elastic/elasticsearch/issues/comments/369823616","html_url":"https://github.com/elastic/elasticsearch/issues/11830#issuecomment-369823616","issue_url":"https://api.github.com/repos/elastic/elasticsearch/issues/11830","id":369823616,"user":{"login":"NidhiChandak","id":36695295,"avatar_url":"https://avatars2.githubusercontent.com/u/36695295?v=4","gravatar_id":"","url":"https://api.github.com/users/NidhiChandak","html_url":"https://github.com/NidhiChandak","followers_url":"https://api.github.com/users/NidhiChandak/followers","following_url":"https://api.github.com/users/NidhiChandak/following{/other_user}","gists_url":"https://api.github.com/users/NidhiChandak/gists{/gist_id}","starred_url":"https://api.github.com/users/NidhiChandak/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/NidhiChandak/subscriptions","organizations_url":"https://api.github.com/users/NidhiChandak/orgs","repos_url":"https://api.github.com/users/NidhiChandak/repos","events_url":"https://api.github.com/users/NidhiChandak/events{/privacy}","received_events_url":"https://api.github.com/users/NidhiChandak/received_events","type":"User","site_admin":false},"created_at":"2018-03-02T05:21:29Z","updated_at":"2018-03-02T05:21:29Z","author_association":"NONE","body":"Hi. With respect to the first example, Is there a way for me to fetch the model only where \"make\" is \"Honda\"? "}}
{"actor":{"display_login":"NidhiChandak"}}