# Updating an index with Scripted Metrics results

**URL:** <https://discuss.elastic.co/t/updating-an-index-with-scripted-metrics-results/168711>\
**Category:** Elasticsearch\
**Created:** [February 17, 2019, 5:51am UTC](https://discuss.elastic.co/t/updating-an-index-with-scripted-metrics-results/168711 "2019-02-17T05:51:41Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![faZhift](https://avatars.discourse-cdn.com/v4/letter/f/91b2a8/32.png) [@faZhift](https://discuss.elastic.co/u/faZhift)\
**Post date:** [February 17, 2019, 5:51am UTC](https://discuss.elastic.co/t/updating-an-index-with-scripted-metrics-results/168711/1 "2019-02-17T05:51:41Z")

</div>

Hello,

I'm performing a Scripted Metric aggregate around a hash value of Documents in order to generate a "Global Owner" result set. Basically, 'every person who owns this Document'.

Upon getting the result set, I then need to apply that result to each Document that has that hash value. I am currently performing an "update by query", searching for each individual hash value and updating the source through scripting with parameters. This is all done in PowerShell.

My question is, is there a better way to get those results saved, per hash value, than the way I'm doing it? I'm sending a REST request for each and every hash, which feels inefficient. I looked into the "bulk" API, but it appeared that I needed to know individual Document information, which is no good. I need to be able to update all Documents that share a hash value.

Apologies if any of this is well-known stuff. I'm new.  
Thanks in advance for any help you folks can give!

---

<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 17, 2019, 5:51am UTC](https://discuss.elastic.co/t/updating-an-index-with-scripted-metrics-results/168711/2 "2019-03-17T05:51:42Z")

</div>

Closed on March 17, 2019, 5:51am UTC

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