{"action":"created","issue":{"url":"https://api.github.com/repos/elastic/elasticsearch-net/issues/3350","repository_url":"https://api.github.com/repos/elastic/elasticsearch-net","labels_url":"https://api.github.com/repos/elastic/elasticsearch-net/issues/3350/labels{/name}","comments_url":"https://api.github.com/repos/elastic/elasticsearch-net/issues/3350/comments","events_url":"https://api.github.com/repos/elastic/elasticsearch-net/issues/3350/events","html_url":"https://github.com/elastic/elasticsearch-net/issues/3350","id":347496943,"node_id":"MDU6SXNzdWUzNDc0OTY5NDM=","number":3350,"title":"ES document's _id is not mapped to C# entity's Id","user":{"login":"maxsel","id":3755559,"node_id":"MDQ6VXNlcjM3NTU1NTk=","avatar_url":"https://avatars1.githubusercontent.com/u/3755559?v=4","gravatar_id":"","url":"https://api.github.com/users/maxsel","html_url":"https://github.com/maxsel","followers_url":"https://api.github.com/users/maxsel/followers","following_url":"https://api.github.com/users/maxsel/following{/other_user}","gists_url":"https://api.github.com/users/maxsel/gists{/gist_id}","starred_url":"https://api.github.com/users/maxsel/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/maxsel/subscriptions","organizations_url":"https://api.github.com/users/maxsel/orgs","repos_url":"https://api.github.com/users/maxsel/repos","events_url":"https://api.github.com/users/maxsel/events{/privacy}","received_events_url":"https://api.github.com/users/maxsel/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2018-08-03T18:37:14Z","updated_at":"2018-08-06T20:31:57Z","closed_at":null,"author_association":"NONE","body":"I have simplistic entity with property named \"Id\" of type String in my C# code.\r\nI also have an index with a number of documents uploaded via Bulk API. Document's schema doesn't include \"id\" field. The only thing that I have is a standard Elasticsearch's \"_id\" property.\r\n\r\nSo when it gets to retrieving documents (`var response = _esClient.Search<Poco>(s => s.MatchAll())`), I clearly see that Id has correct value in every object in `response`'s `Hits` array property.\r\nHowever, when I do `var documents = response.Documents.ToList()`, all my documents has `Id` = `null`.\r\n\r\nWhat I've tried is setting IdProperty in ConnectionSettings - still no luck. So I don't really see a way to map Elasticsearch's \"_id\" to my entity's Id property.\r\n\r\n**Description of the problem including expected versus actual behavior**:\r\n\r\n**NEST/Elasticsearch.Net version**: latest\r\n**Elasticsearch version**: latest\r\n\r\n**Steps to reproduce**:\r\n 1. Create Elasticsearch index with documents.\r\n 2. Create simplest entity with Id property.\r\n 3. `var documents = _esClient.Search<Poco>(s => s.MatchAll()).Documents.ToList()`\r\n\r\nER: `documents` is a list of `Poco`s where each object has `Id` property equal to corresponding document's \"_id\" field in Elasticsearch.\r\nAR: `Id` = `null` in all objects.\r\n\r\n**ConnectionSettings**:\r\n```csharp\r\n            _settings =\r\n                new ConnectionSettings(_node)\r\n                    .DefaultIndex(\"pocos\")\r\n                    .DefaultTypeName(\"doc\")\r\n\r\n                    .DefaultMappingFor<Poco>(\r\n                        m => m\r\n                            .IndexName(\"pocos\")\r\n                            .TypeName(\"doc\")\r\n                            .IdProperty(p => p.Id));  // this one doesn't work anyway\r\n            _esClient = new ElasticClient(_settings);\r\n```"},"comment":{"url":"https://api.github.com/repos/elastic/elasticsearch-net/issues/comments/410843642","html_url":"https://github.com/elastic/elasticsearch-net/issues/3350#issuecomment-410843642","issue_url":"https://api.github.com/repos/elastic/elasticsearch-net/issues/3350","id":410843642,"node_id":"MDEyOklzc3VlQ29tbWVudDQxMDg0MzY0Mg==","user":{"login":"maxsel","id":3755559,"node_id":"MDQ6VXNlcjM3NTU1NTk=","avatar_url":"https://avatars1.githubusercontent.com/u/3755559?v=4","gravatar_id":"","url":"https://api.github.com/users/maxsel","html_url":"https://github.com/maxsel","followers_url":"https://api.github.com/users/maxsel/followers","following_url":"https://api.github.com/users/maxsel/following{/other_user}","gists_url":"https://api.github.com/users/maxsel/gists{/gist_id}","starred_url":"https://api.github.com/users/maxsel/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/maxsel/subscriptions","organizations_url":"https://api.github.com/users/maxsel/orgs","repos_url":"https://api.github.com/users/maxsel/repos","events_url":"https://api.github.com/users/maxsel/events{/privacy}","received_events_url":"https://api.github.com/users/maxsel/received_events","type":"User","site_admin":false},"created_at":"2018-08-06T20:31:57Z","updated_at":"2018-08-06T20:31:57Z","author_association":"NONE","body":"Thanks for explanation @russcam, duplicating document's hit metadata \"_id\" in the source as document's \"id\" field worked for us. Though it's an obvious duplication, the code looks much better without that explicit mapping :)"}}
{"actor":{"display_login":"maxsel"}}