# How to set the property on POCO for ElasticSearch NEST API to serialize it correctly

**URL:** <https://discuss.elastic.co/t/how-to-set-the-property-on-poco-for-elasticsearch-nest-api-to-serialize-it-correctly/231745>\
**Category:** Elasticsearch\
**Created:** [May 8, 2020, 2:31pm UTC](https://discuss.elastic.co/t/how-to-set-the-property-on-poco-for-elasticsearch-nest-api-to-serialize-it-correctly/231745 "2020-05-08T14:31:38Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![itsbalur](https://avatars.discourse-cdn.com/v4/letter/i/d9b06d/32.png) [@itsbalur](https://discuss.elastic.co/u/itsbalur)\
**Post date:** [May 8, 2020, 2:31pm UTC](https://discuss.elastic.co/t/how-to-set-the-property-on-poco-for-elasticsearch-nest-api-to-serialize-it-correctly/231745/1 "2020-05-08T14:31:38Z")

</div>

I have the below POCO for ElasticSearch response

```auto
 public PublicationInfo PublicationInfo { get; }

```

where the PublicationInfo is defined as below

```auto
public class PublicationInfo
    {
        public string Issn { get; }
        public string Volume { get; }
        public string Pagination { get;}
    }

```

The ElasticSearch mapping is as below

```auto
     "publicationinfo" : {
          "properties" : {
            "issn" : {
              "type" : "text",
              "fields" : {
                "keyword" : {
                  "type" : "keyword",
                  "ignore_above" : 256
                }
              }
            },
            "pagination" : {
              "type" : "text",
              "fields" : {
                "keyword" : {
                  "type" : "keyword",
                  "ignore_above" : 256
                }
              }
            },
            "volume" : {
              "type" : "text",
              "fields" : {
                "keyword" : {
                  "type" : "keyword",
                  "ignore_above" : 256
                }
              }
            }
          }
        }

```

When the search response is searialized to POCO, the PublicationInfo property is returned as null although the response has a value.

What needs to be done to have NEST serialize the response correctly to the PublicationInfo property?

ConnectionSettings are as below

```auto
var settings = new ConnectionSettings(pool)
                .DefaultIndex("indexname")
                .DefaultFieldNameInferrer(field => field.ToLower());

```

Using ElasticSearch v7.4 and NEST v7.4

---

<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:** [May 8, 2020, 11:12pm UTC](https://discuss.elastic.co/t/how-to-set-the-property-on-poco-for-elasticsearch-nest-api-to-serialize-it-correctly/231745/2 "2020-05-08T23:12:00Z")

</div>

The properties need a setter in order for the serializer to be able to set properties on them.

---

<div class="post-metadata">

**Author:** ![itsbalur](https://avatars.discourse-cdn.com/v4/letter/i/d9b06d/32.png) [@itsbalur](https://discuss.elastic.co/u/itsbalur)\
**Post date:** [May 9, 2020, 5:32am UTC](https://discuss.elastic.co/t/how-to-set-the-property-on-poco-for-elasticsearch-nest-api-to-serialize-it-correctly/231745/3 "2020-05-09T05:32:40Z")

</div>

Many thanks. I was sure I was missing something obvious. 🙂

---

<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:** [June 6, 2020, 5:36am UTC](https://discuss.elastic.co/t/how-to-set-the-property-on-poco-for-elasticsearch-nest-api-to-serialize-it-correctly/231745/4 "2020-06-06T05:36:39Z")

</div>

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