BUG? Attachment type in nested object work abnormal

when I used attachment type in normal field like "file",it work well.

However, when I use attachment type in nested object, it work abnormal: no content but base64 and it cann't be highlight, too. I add "include_in_root": true but still not work.

{
  "attachment": {
    "properties": {
      "file": {
        "type": "nested",
        "include_in_root": true,
        "properties": {
          "name": {
            "type": "string",
            "store": "yes"
          },
          "content": {
            "type": "attachment",
            "include_in_root": true,
            "copy_to": "copy",
            "fields": {
              "file": {
                "store": "yes",
                "index": "analyzed",
                "include_in_root": true,
                "copy_to": "copy"
              },
              "title": {
                "include_in_root": true,
                "copy_to": "copy",
                "store": "yes"
              },
              "date": {
                "include_in_root": true,
                "copy_to": "copy",
                "store": "yes"
              },
              "author": {
                "include_in_root": true,
                "copy_to": "copy",
                "store": "yes"
              },
              "keywords": {
                "include_in_root": true,
                "copy_to": "copy",
                "store": "yes"
              },
              "content_type": {
                "include_in_root": true,
                "copy_to": "copy",
                "store": "yes"
              },
              "content_length": {
                "include_in_root": true,
                "copy_to": "copy",
                "store": "yes"
              },
              "language": {
                "include_in_root": true,
                "copy_to": "copy",
                "store": "yes"
              }
            }
          }
        }
      },
      "copy": {
        "type": "string",
        "store": "yes"
      }
    }
  }
}

Is there something wrong?

include_in_root is not supported for the attachment type but should work fine with inner fields.
Same for copy_to. You can copy the content of a sub field of an attachment object but not the attachment object itself.

Thx for your answer~

So I cannot use attachment type in inner fields if I want to highlight it? Maybe ES should add an explain about attachment type in inner field in doc( https://github.com/elastic/elasticsearch-mapper-attachments#mapper-attachments-type-for-elasticsearch)

I did not mean that.
Highlighting in nested should work. Copying from attachment sub fields to another field as well.
Include in parent from attachment sub field as well.

Give it a try.

If it does not work, please provide a full script to reproduce your issue so we can check what is wrong.

mapping request:

   -PUT hermestest1/email/_mappings 
   {
      "email": {
        "properties": {
          "attachment": {
            "type": "nested",
            "properties": {
              "name": {
                "type": "string",
                "store": "yes"
              },
              "content": {
                "type": "attachment",
                "fields": {
                  "file": {
                    "store": "yes",
                    "index": "analyzed"
                  },
                  "title": {
                    "store": "yes"
                  },
                  "date": {
                    "store": "yes"
                  },
                  "author": {
                    "store": "yes"
                  },
                  "keywords": {
                    "store": "yes"
                  },
                  "content_type": {
                    "store": "yes"
                  },
                  "content_length": {
                    "store": "yes"
                  },
                  "language": {
                    "store": "yes"
                  }
                }
              }
            }
          }
        }
      }
    }

add a doc:

curl -XPOST "http://IP:port/hermestest1/email/1" -d {
 "attachment":[{"name":"my doc", "content":"base64...""}]
}

query :

  -XPOST  hermestest1/email/_search?pretty=true
        {
          "query": {
            "nested": {
              "path": "attachment",
              "query": {
                "term": {
                  "attachment.content": "搜索"
                }
              }
            }
          },
          "fields": [
            "attachment.content.title",
            "attachment.content.author",
            "attachment.content.date",
            "attachment.content.content_type",
            "attachment.content",
            "attachment.name"
          ],
          "highlight": {
            "pre_tags": [
              "<b>"
            ],
            "post_tags": [
              "</b>"
            ],
            "require_field_match": true,
            "fields": {
              "attachment.content": {}
            }
          }
        }
    

    query return:

        { 
           "took": 33,
           "timed_out": false,
           "_shards": { "total": 5,"successful": 5,"failed": 0},
           "hits": { 
                  "total": 1,
                  "max_score": 0.35355338,
                  "hits": [ 
                      { 
                         "_index": "hermestest1",
                         "_type": "email",
                         "_id": "1",
                         "_score": 0.35355338,
                         "fields": { "attachment.content": [ "**base64....**" ]}
                     }
                ]
          }
    }