# NEST API - Document Suggester Document Id

**URL:** https://discuss.elastic.co/t/nest-api-document-suggester-document-id/126278
**Category:** Elasticsearch
**Created:** [March 30, 2018, 7:43pm UTC](https://discuss.elastic.co/t/nest-api-document-suggester-document-id/126278 "2018-03-30T19:43:58Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![han1](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/han1/32/20141_2.png) [@han1](https://discuss.elastic.co/u/han1)
#### Post date: [March 30, 2018, 7:43pm UTC](https://discuss.elastic.co/t/nest-api-document-suggester-document-id/126278/1 "2018-03-30T19:43:58Z")

</div>

I know that if you have a field called Id, then Elasticsearch will use that field as the Id of the document.

However, we want Elasticsearch to create the Ids for us.

We are using the Suggester and we need to access the Id of each document that is returned.

With the NEST API, there is a property called Nest.Id, however, it is an object and does not have any public properties for us to use in order to get the actual value it represents.

Is there any way we can get this Id value from the Nest.Id object.

Many thanks

---

<div class="post-metadata">

### Author: ![forloop](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/forloop/32/9021_2.png) [@forloop](https://discuss.elastic.co/u/forloop)
#### Post date: [March 31, 2018, 5:55am UTC](https://discuss.elastic.co/t/nest-api-document-suggester-document-id/126278/2 "2018-03-31T05:55:30Z")

</div>

> [@han1](#):
>
> However, we want Elasticsearch to create the Ids for us.

If you don't have an `Id` field on the POCO that represents the document, then upon indexing, Elasticsearch will create an id for the document and populate the `_id` field on the document metadata. You need to be sure to always provide this id whenever you're interacting with the document, such as updating it; the value can be supplied using the `Id` property on the request type, or `.Id()` method on the fluent API descriptor.

> [@han1](#):
>
> We are using the Suggester and we need to access the Id of each document that is returned.
> 
> With the NEST API, there is a property called Nest.Id, however, it is an object and does not have any public properties for us to use in order to get the actual value it represents.

You can access the `_id` on the hits metadata which is mapped as `Nest.Id` with

```auto
var myCompletionSuggest = response.Suggest["my-completion-suggest"];

var suggest = myCompletionSuggest.First();
var option = suggest.Options.First();

// in this instance, you could pass null instead of connection settings
var idValue = ((IUrlParameter)option.Id).GetString(connectionSettings);

```

I think `Index` and `Id` ought to be mapped as `string` here though, to help in using them.

---

<div class="post-metadata">

### Author: ![han1](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/han1/32/20141_2.png) [@han1](https://discuss.elastic.co/u/han1)
#### Post date: [March 31, 2018, 6:01pm UTC](https://discuss.elastic.co/t/nest-api-document-suggester-document-id/126278/3 "2018-03-31T18:01:05Z")

</div>

Many,Many Thanks Russ.

I will try this.

Regards

Hassan

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)
#### Post date: [April 28, 2018, 6:01pm UTC](https://discuss.elastic.co/t/nest-api-document-suggester-document-id/126278/4 "2018-04-28T18:01:05Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
