# Scripted field

**URL:** <https://discuss.elastic.co/t/scripted-field/242881>\
**Category:** Kibana\
**Created:** [July 28, 2020, 10:24am UTC](https://discuss.elastic.co/t/scripted-field/242881 "2020-07-28T10:24:20Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![inhinyera16](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/inhinyera16/32/61625_2.png) [@inhinyera16](https://discuss.elastic.co/u/inhinyera16)\
**Post date:** [July 28, 2020, 10:24am UTC](https://discuss.elastic.co/t/scripted-field/242881/1 "2020-07-28T10:24:21Z")

</div>

Hi everyone

I created a scripted field to extract the hour of the week from @timestamp

doc['@timestamp'].value.hour

and its working fine.

But when i try to extract the day of week using this query in dev tools

GET filebeat-7.8\*/\_search  
{  
"script\_fields": {  
"birth\_year": {  
"script": {  
"source": "doc['@timestamp'].value.dayOfWeek"  
}  
}  
}  
}

It's working fine as well but this scripted field gives me shard failed error when i use discover for filebeat-7.8\*.

Can anyone share how to get the day of week using scripted field? i will use thi scripted in visualizations

---

<div class="post-metadata">

**Author:** ![matw](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/matw/32/13913_2.png) [@matw](https://discuss.elastic.co/u/matw)\
**Post date:** [August 3, 2020, 5:57am UTC](https://discuss.elastic.co/t/scripted-field/242881/2 "2020-08-03T05:57:52Z")

</div>

Hi

Could you provide the shard error you're receiving in Discover?

Many thx!  
Best,  
Matthias

---

<div class="post-metadata">

**Author:** ![inhinyera16](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/inhinyera16/32/61625_2.png) [@inhinyera16](https://discuss.elastic.co/u/inhinyera16)\
**Post date:** [August 3, 2020, 7:43am UTC](https://discuss.elastic.co/t/scripted-field/242881/3 "2020-08-03T07:43:44Z")

</div>

Hi.

turns out that the scripted field function dayofweek is depreciated in version 7.8.  
Also the mapping type for IP in version 7.7 and 7.8 is different so we remove the 7.7 indices and reindex using 7.8. Until then it works fine. The mapping conflict caused the error.

---

<div class="post-metadata">

**Author:** ![matw](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/matw/32/13913_2.png) [@matw](https://discuss.elastic.co/u/matw)\
**Post date:** [August 3, 2020, 11:58am UTC](https://discuss.elastic.co/t/scripted-field/242881/4 "2020-08-03T11:58:10Z")

</div>

Thank you for sharing! so it's solved, right?

---

<div class="post-metadata">

**Author:** ![inhinyera16](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/inhinyera16/32/61625_2.png) [@inhinyera16](https://discuss.elastic.co/u/inhinyera16)\
**Post date:** [August 3, 2020, 1:09pm UTC](https://discuss.elastic.co/t/scripted-field/242881/5 "2020-08-03T13:09:44Z")

</div>

yes i believe so, thanks man!

---

<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 31, 2020, 1:09pm UTC](https://discuss.elastic.co/t/scripted-field/242881/6 "2020-08-31T13:09:47Z")

</div>

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