Incorrect attachment field names after indexing

(Иван Сорокин) #1

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
        public String Name { get; set; }
        public Guid Id { get; set; }

        public Attachment Attachment { get; set; } //Nest class
        public JoinField Join { get; set; }
        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>
    public string Author { get; set; }

    /// <summary>The base64 encoded content. Can be explicitly set</summary>
    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,
                                                                                                               () =>
                                                                                                                       TypeNameHandling = TypeNameHandling.Auto
var connectionSettings =
    new ConnectionSettings(connectionPool, sourceSerializer: sourceSerializerFactory);

(system) closed #2

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