{"action":"created","issue":{"url":"https://api.github.com/repos/elastic/elasticsearch-mapper-attachments/issues/190","labels_url":"https://api.github.com/repos/elastic/elasticsearch-mapper-attachments/issues/190/labels{/name}","comments_url":"https://api.github.com/repos/elastic/elasticsearch-mapper-attachments/issues/190/comments","events_url":"https://api.github.com/repos/elastic/elasticsearch-mapper-attachments/issues/190/events","html_url":"https://github.com/elastic/elasticsearch-mapper-attachments/issues/190","id":117327728,"number":190,"title":"copy_to of metadata field isn't working (v3.0.2)","user":{"login":"gpaul","id":442,"avatar_url":"https://avatars.githubusercontent.com/u/442?v=3","gravatar_id":"","url":"https://api.github.com/users/gpaul","html_url":"https://github.com/gpaul","followers_url":"https://api.github.com/users/gpaul/followers","following_url":"https://api.github.com/users/gpaul/following{/other_user}","gists_url":"https://api.github.com/users/gpaul/gists{/gist_id}","starred_url":"https://api.github.com/users/gpaul/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gpaul/subscriptions","organizations_url":"https://api.github.com/users/gpaul/orgs","repos_url":"https://api.github.com/users/gpaul/repos","events_url":"https://api.github.com/users/gpaul/events{/privacy}","received_events_url":"https://api.github.com/users/gpaul/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/elastic/elasticsearch-mapper-attachments/labels/bug","name":"bug","color":"e11d21"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":5,"created_at":"2015-11-17T10:43:45Z","updated_at":"2015-11-23T15:02:19Z","closed_at":null,"body":"The following set of steps against a fresh elasticsearch 2.0.0 instance with v3.0.2 of this plugin installed shows that copy_to isn't working for the name field. I doubt it is working for the other metadata fields, either.\r\n\r\nYou can copy/paste this in your shell.\r\n```\r\n# create a mapping\r\ncurl -XPOST 'http://localhost:9200/test_copyto' -d '{\r\n  \"mappings\": {\r\n    \"person\": {\r\n      \"properties\": {\r\n        \"copy_dst\": { \"type\": \"string\" },\r\n        \"doc\": {\r\n\t  \"type\": \"attachment\",\r\n\t  \"fields\": {\r\n\t    \"name\": { \"copy_to\": \"copy_dst\" }\r\n          }\r\n\t}\r\n      }\r\n    }\r\n  }\r\n}'\r\n## => {\"acknowledged\":true}\r\n\r\n\r\n# index a document, specifying a document name\r\ncurl -XPOST 'http://localhost:9200/test_copyto/person/1' -d '{\r\n  \"doc\": {\r\n    \"_content\": \"e1xydGYxXGFuc2kNCkxvcmVtIGlwc3VtIGRvbG9yIHNpdCBhbWV0DQpccGFyIH0=\",\r\n    \"_name\": \"my-attachment-name.doc\"\r\n  }\r\n}'\r\n## => {\"_index\":\"test_copyto\",\"_type\":\"person\",\"_id\":\"1\",\"_version\":1,\"_shards\":{\"total\":2,\"successful\":1,\"failed\":0},\"created\":true}\r\n\r\n\r\n# search for the document by its contents\r\ncurl -XPOST 'http://localhost:9200/test_copyto/person/_search' -d '\r\n{\r\n  \"query\": {\r\n    \"query_string\": {\r\n      \"default_field\": \"doc.content\",\r\n      \"fields\": [\"copy_dst\", \"doc.content\"],\r\n      \"query\": \"ipsum\"\r\n    }\r\n  }\r\n}\r\n'\r\n## => {\"took\":5,\"timed_out\":false,\"_shards\":{\"total\":5,\"successful\":5,\"failed\":0},\"hits\": \"total\":1,\"max_score\":0.04119441,\"hits\":[{\"_index\":\"test_copyto\",\"_type\":\"person\",\"_id\":\"1\",\"_score\":0.04119441,\"_source\":{\r\n#  \"doc\": {\r\n#    \"_content\": \"e1xydGYxXGFuc2kNCkxvcmVtIGlwc3VtIGRvbG9yIHNpdCBhbWV0DQpccGFyIH0=\",\r\n#    \"_name\": \"my-attachment-name.doc\"\r\n#  }\r\n#}}]}}\r\n\r\n\r\n# search for the document by its name\r\ncurl -XPOST 'http://localhost:9200/test_copyto/person/_search' -d '\r\n{\r\n  \"query\": {\r\n    \"query_string\": {\r\n      \"default_field\": \"doc.name\",\r\n      \"fields\": [\"doc.name\"],\r\n      \"query\": \"my-test.doc\"\r\n    }\r\n  }\r\n}\r\n'\r\n## => {\"took\":5,\"timed_out\":false,\"_shards\":{\"total\":5,\"successful\":5,\"failed\":0},\"hits\":{\"total\":1,\"max_score\":0.02250402,\"hits\":[{\"_index\":\"test_copyto\",\"_type\":\"person\",\"_id\":\"1\",\"_score\":0.02250402,\"_source\":{\r\n#  \"doc\": {\r\n#    \"_content\": \"e1xydGYxXGFuc2kNCkxvcmVtIGlwc3VtIGRvbG9yIHNpdCBhbWV0DQpccGFyIH0=\",\r\n#    \"_name\": \"my-attachment-name.doc\"\r\n#  }\r\n#}}]}}\r\n\r\n# search for the document by the copy_dst field\r\ncurl -XPOST 'http://localhost:9200/test_copyto/person/_search' -d '\r\n{\r\n  \"query\": {\r\n    \"query_string\": {\r\n      \"default_field\": \"copy_dst\",\r\n      \"fields\": [\"copy_dst\"],\r\n      \"query\": \"my-test.doc\"\r\n    }\r\n  }\r\n}\r\n'\r\n## => {\"took\":1,\"timed_out\":false,\"_shards\":{\"total\":5,\"successful\":5,\"failed\":0},\"hits\":{\"total\":0,\"max_score\":null,\"hits\":[]}}\r\n```"},"comment":{"url":"https://api.github.com/repos/elastic/elasticsearch-mapper-attachments/issues/comments/158961334","html_url":"https://github.com/elastic/elasticsearch-mapper-attachments/issues/190#issuecomment-158961334","issue_url":"https://api.github.com/repos/elastic/elasticsearch-mapper-attachments/issues/190","id":158961334,"user":{"login":"hhoechtl","id":5076356,"avatar_url":"https://avatars.githubusercontent.com/u/5076356?v=3","gravatar_id":"","url":"https://api.github.com/users/hhoechtl","html_url":"https://github.com/hhoechtl","followers_url":"https://api.github.com/users/hhoechtl/followers","following_url":"https://api.github.com/users/hhoechtl/following{/other_user}","gists_url":"https://api.github.com/users/hhoechtl/gists{/gist_id}","starred_url":"https://api.github.com/users/hhoechtl/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hhoechtl/subscriptions","organizations_url":"https://api.github.com/users/hhoechtl/orgs","repos_url":"https://api.github.com/users/hhoechtl/repos","events_url":"https://api.github.com/users/hhoechtl/events{/privacy}","received_events_url":"https://api.github.com/users/hhoechtl/received_events","type":"User","site_admin":false},"created_at":"2015-11-23T15:02:19Z","updated_at":"2015-11-23T15:02:19Z","body":"It's also not working with the .content field"}}