# Retrieving script field in elasticsearch for ML

**URL:** <https://discuss.elastic.co/t/retrieving-script-field-in-elasticsearch-for-ml/315165>\
**Category:** Elasticsearch\
**Tags:** elastic-stack-machine-learning\
**Created:** [September 26, 2022, 11:41am UTC](https://discuss.elastic.co/t/retrieving-script-field-in-elasticsearch-for-ml/315165 "2022-09-26T11:41:59Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Aniket\_Pant](https://avatars.discourse-cdn.com/v4/letter/a/77aa72/32.png) [@Aniket\_Pant](https://discuss.elastic.co/u/Aniket_Pant)\
**Post date:** [September 26, 2022, 11:41am UTC](https://discuss.elastic.co/t/retrieving-script-field-in-elasticsearch-for-ml/315165/1 "2022-09-26T11:41:59Z")

</div>

Hi Team  
I added this field recently and now i have to apply high function in this field using single metric ML. But this field is not showin , i know this is runtime field but is there any solution for this.

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/4/c/4c9796fc924dfff4f19eed40dc582c70c70b1b51.png)

---

<div class="post-metadata">

**Author:** ![Aniket\_Pant](https://avatars.discourse-cdn.com/v4/letter/a/77aa72/32.png) [@Aniket\_Pant](https://discuss.elastic.co/u/Aniket_Pant)\
**Post date:** [September 26, 2022, 12:46pm UTC](https://discuss.elastic.co/t/retrieving-script-field-in-elasticsearch-for-ml/315165/2 "2022-09-26T12:46:22Z")

</div>

Hi Community  
For testing purpose i've used now runtime field

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/8/1/81902afa5227659e84a0256ba7e6188fa9f4f200.png)

But when i go **Machine Learning -\>Anamoly Detection-\>Create job-\>Advanced Configuration** i go to **Add Detector** option and choose high\_count but i can't select my test field

And for single metric i can select high\_mean for test field , but i want to have high\_count for test field.

Any solution for this problem

---

<div class="post-metadata">

**Author:** ![sophie\_chang](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/sophie_chang/32/18008_2.png) [@sophie\_chang](https://discuss.elastic.co/u/sophie_chang)\
**Post date:** [September 27, 2022, 8:56am UTC](https://discuss.elastic.co/t/retrieving-script-field-in-elasticsearch-for-ml/315165/3 "2022-09-27T08:56:43Z")

</div>

Here are a few options, but I'm not entirely sure what you are trying to achieve.

The `count` functions count the event rate and do not support a field selection. These functions count the number of documents. If you are trying to analyse the event rate of docs where a field exists, then use `high_count` and add an `exists` query to your detector.

Alternatively, if the field `test` already contains a count value (meaning the data is pre-summarised) then use the `high_count` function with a `summary_count_field_name: test`.

Alternatively, if you are trying to analyse a numeric value, then perhaps use `high_sum(test)` or `high_mean(test)`.

More info here [Function reference | Machine Learning in the Elastic Stack [8.4] | Elastic](https://www.elastic.co/guide/en/machine-learning/current/ml-functions.html)

Hope this helps.

---

<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:** [October 25, 2022, 8:57am UTC](https://discuss.elastic.co/t/retrieving-script-field-in-elasticsearch-for-ml/315165/4 "2022-10-25T08:57:27Z")

</div>

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