Nest 2 中的附件字段未正确映射

Attachment field not mapped correctly in Nest 2

正在尝试像这样映射附件属性:

client.Map<Case>(m => m.UpdateAllTypes());

有了这个 类 和映射定义:

[ElasticsearchType(Name = "cases")]
public class Case
{
    public string Author { get; set; }
    public string CaseName { get; set; }
    [Attachment(Store = true)]
    public Attachment File { get; set; }

}


public class Attachment
{
    [String(Name = "_content")]
    public string Content { get; set; }

    [String(Name = "_content_type")]
    public string ContentType { get; set; }

    [String(Name = "_name")]
    public string Name { get; set; }

}

产生了这个生成的映射

"mappings": {
  "cases": {
    "properties": {
      "author": {
        "type": "string"
      },
      "case_name": {
        "type": "string"
      },
      "file": {
        "properties": {
          "_content": {
            "type": "string"
          },
          "_content_type": {
            "type": "string"
          },
          "_name": {
            "type": "string"
          }
        }
      }
    }
  }

是的,文件 属性 定义中缺少 "type": "attachment"

使用 Elasticsearch 2.2、Nest 2.0.2、Mono/.Net 4.5

此映射在 this issue 修复后有效:

[ElasticsearchType(Name = "cases")]
public class Case
{
    public Case()
    {
    }

    [String(Name = "case_name")]
    public string CaseName { get; set; }

    [String(Name = "md5")]
    public string Md5 { get; set; }

    [Attachment(Name="file")]
    public Attachment File { get; set; }

}


public class Attachment
{
    public Attachment()
    {

    }

    [String(Name = "_author")]
    public string Author { get; set; }

    [String(Name = "_content_lenght")]
    public long ContentLength { get; set; }

    [String(Name = "_content_type")]
    public string ContentType { get; set; }

    [Date(Name = "_date")]
    public DateTime Date { get; set; }

    [String(Name = "_keywords")]
    public string Keywords { get; set; }

    [String(Name = "_language")]
    public string Language { get; set; }

    [String(Name = "_name")]
    public string Name { get; set; }

    [String(Name = "_title")]
    public string Title { get; set; }

    [String(Name = "_content")]
    public string Content { get; set; }

}