# Disable dynamic mapping for index except for 1 field

**URL:** https://discuss.elastic.co/t/disable-dynamic-mapping-for-index-except-for-1-field/163531
**Category:** Elasticsearch
**Created:** [January 9, 2019, 12:48pm UTC](https://discuss.elastic.co/t/disable-dynamic-mapping-for-index-except-for-1-field/163531 "2019-01-09T12:48:21Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![Keff](https://avatars.discourse-cdn.com/v4/letter/k/eada6e/32.png) [@Keff](https://discuss.elastic.co/u/Keff)
#### Post date: [January 9, 2019, 12:48pm UTC](https://discuss.elastic.co/t/disable-dynamic-mapping-for-index-except-for-1-field/163531/1 "2019-01-09T12:48:21Z")

</div>

I want to index documents where same fields can have different data types. My documents look like this:

```
{
	"user": "testuser",
	"field1": "arbitraryDataTypeValue",
	"field2": "arbitraryDataTypeValue"

    ...n fields...
}

```

Therefore I can disable the mapping like this:

```
PUT myIndex
{
  "mappings": {
    "default": {
          "enabled": false
    }
  }
}

```

The drawback is, that the fields cannot be searched.

My problem is, that I have only one field "user", that should be searchable and I do not want to disable all other fields explicitly one by one.

Is there a way to disable the mapping of all fields except for one?

Something like this:

```
PUT myIndex
{
	"mappings": {
		"default": {
			"enabled": false,
			"properties": {
				"user": {
					"enabled": true
				}
			}
		}
	}
}
```

---

<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: [February 6, 2019, 12:48pm UTC](https://discuss.elastic.co/t/disable-dynamic-mapping-for-index-except-for-1-field/163531/2 "2019-02-06T12:48:23Z")

</div>

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