# Enabled property not working for dynamic string type fields

**URL:** <https://discuss.elastic.co/t/enabled-property-not-working-for-dynamic-string-type-fields/92793>\
**Category:** Elasticsearch\
**Created:** [July 12, 2017, 10:46am UTC](https://discuss.elastic.co/t/enabled-property-not-working-for-dynamic-string-type-fields/92793 "2017-07-12T10:46:10Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Surabhi\_Prasad](https://avatars.discourse-cdn.com/v4/letter/s/e19adc/32.png) [@Surabhi\_Prasad](https://discuss.elastic.co/u/Surabhi_Prasad)\
**Post date:** [July 12, 2017, 10:46am UTC](https://discuss.elastic.co/t/enabled-property-not-working-for-dynamic-string-type-fields/92793/1 "2017-07-12T10:46:10Z")

</div>

I have been trying to create an index which would not index any field if no dynamic/implicit template is defined for a field.

PUT [http://localhost:9200/test1](http://localhost:9200/test1)

> ```
> {
> "mappings": {
> "my_type": {
> "dynamic_templates": [
> {
> "indexed": {
> "path_match": "indexed.*",
> "match_mapping_type": "string",
> "mapping": {
> "type": "keyword"
> }
> }
> },
> {
> "others": {
> "path_match": "others.*",
> "match_mapping_type": "string",
> "mapping": {                     
> "enabled": false
> }
> }
> }
> ]
> }
> }
> }
> 
> ```

As per the above setting the below document should get indexed, but it throws error:

POST [http://localhost:9200/test1/my\_type](http://localhost:9200/test1/my_type)

```
{
   "indexed": {
      "a": "c"
   },
   "others": {
      "somerandome": "qqqss",
      "somerandome.www": "qqqss"
      
   }
}

```

Error:

```
{
   "error": {
      "root_cause": [
         {
            "type": "illegal_argument_exception",
            "reason": "Can't merge a non object mapping [others.somerandome] with an object mapping [others.somerandome]"
         }
      ],
      "type": "illegal_argument_exception",
      "reason": "Can't merge a non object mapping [others.somerandome] with an object mapping [others.somerandome]"
   },
   "status": 400
}

```

Also, looking at the code, it seems i can only use enabled:false for object type fields.

Also tried creating static template for a keyword type field as enabled:false and got error.

PUT [http://localhost:9200/test2](http://localhost:9200/test2)

> ```
> {
> "mappings": {
> "my_type": {         
> "properties": {
> "others": {
> "type": "object",
> "properties": {
> "somerandome": {
> "type": "keyword",
> "enabled": false
> }
> }
> }
> }
> }
> }
> }
> 
> ```

Error:

```
{
   "error": {
      "root_cause": [
         {
            "type": "mapper_parsing_exception",
            "reason": "Mapping definition for [somerandome] has unsupported parameters: [enabled : false]"
         }
      ],
      "type": "mapper_parsing_exception",
      "reason": "Failed to parse mapping [my_type]: Mapping definition for [somerandome] has unsupported parameters: [enabled : false]",
      "caused_by": {
         "type": "mapper_parsing_exception",
         "reason": "Mapping definition for [somerandome] has unsupported parameters: [enabled : false]"
      }
   },
   "status": 400
}

```

---

<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:** [August 9, 2017, 10:46am UTC](https://discuss.elastic.co/t/enabled-property-not-working-for-dynamic-string-type-fields/92793/2 "2017-08-09T10:46:21Z")

</div>

Closed on August 9, 2017, 10:46am UTC

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