# Custom type field example not work in Elasticsearch 7.6

**URL:** <https://discuss.elastic.co/t/custom-type-field-example-not-work-in-elasticsearch-7-6/220031>\
**Category:** Elasticsearch\
**Created:** [February 19, 2020, 4:48pm UTC](https://discuss.elastic.co/t/custom-type-field-example-not-work-in-elasticsearch-7-6/220031 "2020-02-19T16:48:51Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![andrewbien](https://avatars.discourse-cdn.com/v4/letter/a/b2d939/32.png) [@andrewbien](https://discuss.elastic.co/u/andrewbien)\
**Post date:** [February 19, 2020, 4:48pm UTC](https://discuss.elastic.co/t/custom-type-field-example-not-work-in-elasticsearch-7-6/220031/1 "2020-02-19T16:48:51Z")

</div>

Hi everyone, I got a problem when I try to run an example of **Custom type field** section in this tutorial: [https://www.elastic.co/guide/en/elasticsearch/reference/7.6/removal-of-types.html#\_custom\_type\_field](https://www.elastic.co/guide/en/elasticsearch/reference/7.6/removal-of-types.html#_custom_type_field)

I executed this query:  
PUT twitter  
{  
"mappings": {  
"user": {  
"properties": {  
"name": { "type": "text" },  
"user\_name": { "type": "keyword" },  
"email": { "type": "keyword" }  
}  
},  
"tweet": {  
"properties": {  
"content": { "type": "text" },  
"user\_name": { "type": "keyword" },  
"tweeted\_at": { "type": "date" }  
}  
}  
}  
}

The result is an error:  
{  
"error" : {  
"root\_cause" : [  
{  
"type" : "mapper\_parsing\_exception",  
"reason" : "Root mapping definition has unsupported parameters: [tweet : {properties={tweeted\_at={type=date}, user\_name={type=keyword}, content={type=text}}}] [user : {properties={user\_name={type=keyword}, name={type=text}, email={type=keyword}}}]"  
}  
],  
"type" : "mapper\_parsing\_exception",  
"reason" : "Failed to parse mapping [\_doc]: Root mapping definition has unsupported parameters: [tweet : {properties={tweeted\_at={type=date}, user\_name={type=keyword}, content={type=text}}}] [user : {properties={user\_name={type=keyword}, name={type=text}, email={type=keyword}}}]",  
"caused\_by" : {  
"type" : "mapper\_parsing\_exception",  
"reason" : "Root mapping definition has unsupported parameters: [tweet : {properties={tweeted\_at={type=date}, user\_name={type=keyword}, content={type=text}}}] [user : {properties={user\_name={type=keyword}, name={type=text}, email={type=keyword}}}]"  
}  
},  
"status" : 400  
}

Can anyone help me with that, thanks in advance!

---

<div class="post-metadata">

**Author:** ![andrewbien](https://avatars.discourse-cdn.com/v4/letter/a/b2d939/32.png) [@andrewbien](https://discuss.elastic.co/u/andrewbien)\
**Post date:** [February 20, 2020, 7:45am UTC](https://discuss.elastic.co/t/custom-type-field-example-not-work-in-elasticsearch-7-6/220031/2 "2020-02-20T07:45:10Z")

</div>

I updated the query I got the error:

```
PUT twitter

```

{  
"mappings": {  
"user": {  
"properties": {  
"name": { "type": "text" },  
"user\_name": { "type": "keyword" },  
"email": { "type": "keyword" }  
}  
},  
"tweet": {  
"properties": {  
"content": { "type": "text" },  
"user\_name": { "type": "keyword" },  
"tweeted\_at": { "type": "date" }  
}  
}  
}  
}

---

<div class="post-metadata">

**Author:** ![spinscale](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/spinscale/32/25011_2.png) [@spinscale](https://discuss.elastic.co/u/spinscale)\
**Post date:** [February 20, 2020, 7:51am UTC](https://discuss.elastic.co/t/custom-type-field-example-not-work-in-elasticsearch-7-6/220031/3 "2020-02-20T07:51:52Z")

</div>

This is supposed to not work on newer versions, as it resembles the old way of using types. The next snippet shows you the working alternative.

---

<div class="post-metadata">

**Author:** ![andrewbien](https://avatars.discourse-cdn.com/v4/letter/a/b2d939/32.png) [@andrewbien](https://discuss.elastic.co/u/andrewbien)\
**Post date:** [February 20, 2020, 8:09am UTC](https://discuss.elastic.co/t/custom-type-field-example-not-work-in-elasticsearch-7-6/220031/4 "2020-02-20T08:09:14Z")

</div>

Thanks @spinscale for your quick reply. Can you show me more detail? I'm still confusing.

So in the document show that:

> Blockquote  
> Of course, there is a limit to how many primary shards can exist in a cluster so you may not want to waste an entire shard for a collection of only a few thousand documents. In this case, you can implement your own custom `type` field which will work in a similar way to the old `_type` .

Yes, I don't want to waste a shard for a few documents, thus I have to implement "Custom type field". If you show me more detail, it would be great, thanks 🙂

---

<div class="post-metadata">

**Author:** ![andrewbien](https://avatars.discourse-cdn.com/v4/letter/a/b2d939/32.png) [@andrewbien](https://discuss.elastic.co/u/andrewbien)\
**Post date:** [February 20, 2020, 8:16am UTC](https://discuss.elastic.co/t/custom-type-field-example-not-work-in-elasticsearch-7-6/220031/5 "2020-02-20T08:16:28Z")

</div>

Hi @spinscale Ha now I got it. Thanks 🙂

---

<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:** [March 19, 2020, 8:16am UTC](https://discuss.elastic.co/t/custom-type-field-example-not-work-in-elasticsearch-7-6/220031/6 "2020-03-19T08:16:31Z")

</div>

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