# Incorrect attachment field names after indexing

**URL:** <https://discuss.elastic.co/t/incorrect-attachment-field-names-after-indexing/159142>\
**Category:** Elasticsearch\
**Created:** [December 3, 2018, 10:26am UTC](https://discuss.elastic.co/t/incorrect-attachment-field-names-after-indexing/159142 "2018-12-03T10:26:10Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![7ca884569f2642e2c488](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/7ca884569f2642e2c488/32/75102_2.png) [@7ca884569f2642e2c488](https://discuss.elastic.co/u/7ca884569f2642e2c488)\
**Post date:** [December 3, 2018, 10:26am UTC](https://discuss.elastic.co/t/incorrect-attachment-field-names-after-indexing/159142/1 "2018-12-03T10:26:11Z")

</div>

**NEST/Elasticsearch.Net version** : 6.4.0

**Elasticsearch version** : 6.5.1

**Description of the problem including expected versus actual behavior** : I am reindexing some document from 5.0 ES index to 6.5.1 using NEST client and bulk update. I am migrating document like this

```auto
Func<BulkIndexDescriptor<T>, BulkIndexDescriptor<T>> bulkIndexSelector = op =>
    {
        var desc = op.Document(hit.Source);
        if (ensureSameRouting)
            desc = desc.Routing(hit.Routing);
        if (indexName != null)
            desc = desc.Index(indexName);
        return desc;
    };

```

while scrolling documents in the older index. T is the class

```auto
[ElasticsearchType(Name = "notifications")]
    public class AttachmentElasticDocument
    {
        [Keyword]
        public String Name { get; set; }
        
        [Keyword]
        public Guid Id { get; set; }

        public Attachment Attachment { get; set; } //Nest class
        
        public JoinField Join { get; set; }
        
        [Keyword]
        public string Data { get; set; }
    }

```

After this I got documents with \_ in the attachment field

```auto
attachment : {
   "_content": "text",
   "_language": "ru"
}

```

So my queries are not working because they are expecting "content" field name without underscore.  
Then I decompiled the source and found this

```auto
  [ContractJsonConverter(typeof (AttachmentConverter))]
  public class Attachment
  {
    /// <summary>The author.</summary>
    [JsonProperty("author")]
    public string Author { get; set; }

    /// <summary>The base64 encoded content. Can be explicitly set</summary>
    [JsonProperty("content")]
    public string Content { get; set; }

    ...and so on
  }

```

No underscores are here in attributes too. How to get rid of them in the index?  
I am using NEST Serializer.

```auto
ConnectionSettings.SourceSerializerFactory sourceSerializerFactory = (builtin, setts) => new JsonNetSerializer(builtin,
                                                                                                               setts,
                                                                                                               () =>
                                                                                                                   new
                                                                                                                   JsonSerializerSettings
                                                                                                                   {
                                                                                                                       TypeNameHandling = TypeNameHandling.Auto
                                                                                                                   });
var connectionSettings =
    new ConnectionSettings(connectionPool, sourceSerializer: sourceSerializerFactory);

```

---

<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:** [December 31, 2018, 10:26am UTC](https://discuss.elastic.co/t/incorrect-attachment-field-names-after-indexing/159142/2 "2018-12-31T10:26:20Z")

</div>

Closed on December 31, 2018, 10:26am UTC

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