Incorrect attachment field names after indexing

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

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

[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

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

  [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.

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

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