# Exclude meta-fileds from \_all

**URL:** https://discuss.elastic.co/t/exclude-meta-fileds-from-all/145724
**Category:** Elasticsearch
**Created:** [August 23, 2018, 12:38pm UTC](https://discuss.elastic.co/t/exclude-meta-fileds-from-all/145724 "2018-08-23T12:38:25Z")
**Posts on this page:** 8
**Page:** 1

<div class="post-metadata">

### Author: ![nikitakrasnov](https://avatars.discourse-cdn.com/v4/letter/n/b3f665/32.png) [@nikitakrasnov](https://discuss.elastic.co/u/nikitakrasnov)
#### Post date: [August 23, 2018, 12:38pm UTC](https://discuss.elastic.co/t/exclude-meta-fileds-from-all/145724/1 "2018-08-23T12:38:26Z")

</div>

Hello.  
Is there the way to exclude meta-fields (for example \_id) from \_all field?

---

<div class="post-metadata">

### Author: ![rjernst](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rjernst/32/6363_2.png) [@rjernst](https://discuss.elastic.co/u/rjernst)
#### Post date: [August 24, 2018, 4:33pm UTC](https://discuss.elastic.co/t/exclude-meta-fileds-from-all/145724/2 "2018-08-24T16:33:14Z")

</div>

The `_all` field is deprecated, and will be removed in 7.0. You can build your own custom `_all` equivalent with `copy_to`. See the [\_all docs](https://www.elastic.co/guide/en/elasticsearch/reference/current/mapping-all-field.html#custom-all-fields).

---

<div class="post-metadata">

### Author: ![nikitakrasnov](https://avatars.discourse-cdn.com/v4/letter/n/b3f665/32.png) [@nikitakrasnov](https://discuss.elastic.co/u/nikitakrasnov)
#### Post date: [August 28, 2018, 3:39pm UTC](https://discuss.elastic.co/t/exclude-meta-fileds-from-all/145724/3 "2018-08-28T15:39:42Z")

</div>

Ryan thank you for your answer. We know about copy\_to but copy\_to doesn't support nested document.  
we have json documents like this

```
    {
    	"name": "Jeck",
    	"dynamic_fields": [{"f1":"v1"}, {"f2":"v2"}]}
    }

```

where structure of dynamic\_fields is not known for us befor we recive this document.  
We tried to set index mapping like this

```
{
	"mappings": {
		"doc": {
			"properties": {
                "dynamic_fields": {
					"type": "nested",
                    "copy_to": "full_txt"
				},
         
                "full_txt": {
					"type": "text"
				}
			}
		}
	}
}

```

But it doesn't work. We get **"Mapping definition for [dynamic\_fields] has unsupported parameters: [copy\_to : full\_txt]"**. This case is so important for us.

Is there way how we can solve this issue?

---

<div class="post-metadata">

### Author: ![rjernst](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rjernst/32/6363_2.png) [@rjernst](https://discuss.elastic.co/u/rjernst)
#### Post date: [August 28, 2018, 3:58pm UTC](https://discuss.elastic.co/t/exclude-meta-fileds-from-all/145724/4 "2018-08-28T15:58:50Z")

</div>

`copy_to` needs to be on a concrete field (ie not nested or object fields). If you don't know all the sub fields within your nested field, you could add the copy\_to automatically using [dynamic templates](https://www.elastic.co/guide/en/elasticsearch/reference/current/dynamic-templates.html).

---

<div class="post-metadata">

### Author: ![nikitakrasnov](https://avatars.discourse-cdn.com/v4/letter/n/b3f665/32.png) [@nikitakrasnov](https://discuss.elastic.co/u/nikitakrasnov)
#### Post date: [August 29, 2018, 12:32pm UTC](https://discuss.elastic.co/t/exclude-meta-fileds-from-all/145724/5 "2018-08-29T12:32:14Z")

</div>

Ryan, If I understood correct, you suggested to use config like this

```
"dynamic_templates": [{
    		"full_txt_t": {
    			"path_match": "dynamic_fields.*",
    			"mapping": {
    				"copy_to": "full_txt"
    			}
    		}
    	}
    ]

```

Does it impact performance when we insert documents? Will ES check matching all field names with path\_match in template? How much impact can It make on performance?

---

<div class="post-metadata">

### Author: ![rjernst](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rjernst/32/6363_2.png) [@rjernst](https://discuss.elastic.co/u/rjernst)
#### Post date: [August 29, 2018, 8:07pm UTC](https://discuss.elastic.co/t/exclude-meta-fileds-from-all/145724/6 "2018-08-29T20:07:00Z")

</div>

Dynamic templates only affect when a field does not yet exist, so it should not have a meaningful impact on performance. Whether a dynamic template exists, a field mapping must exist and will be created automatically when a field name is not found in the existing mappings.

---

<div class="post-metadata">

### Author: ![nikitakrasnov](https://avatars.discourse-cdn.com/v4/letter/n/b3f665/32.png) [@nikitakrasnov](https://discuss.elastic.co/u/nikitakrasnov)
#### Post date: [August 30, 2018, 5:51am UTC](https://discuss.elastic.co/t/exclude-meta-fileds-from-all/145724/7 "2018-08-30T05:51:24Z")

</div>

Thank you very much. It is helpful for us

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)
#### Post date: [September 27, 2018, 5:51am UTC](https://discuss.elastic.co/t/exclude-meta-fileds-from-all/145724/8 "2018-09-27T05:51:27Z")

</div>

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