# Pull data periodically from an Elasticsearch index

**URL:** https://discuss.elastic.co/t/pull-data-periodically-from-an-elasticsearch-index/241962
**Category:** Logstash
**Created:** [July 21, 2020, 3:52am UTC](https://discuss.elastic.co/t/pull-data-periodically-from-an-elasticsearch-index/241962 "2020-07-21T03:52:07Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![pk.241011](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/pk.241011/32/86285_2.png) [@pk.241011](https://discuss.elastic.co/u/pk.241011)
#### Post date: [July 21, 2020, 3:52am UTC](https://discuss.elastic.co/t/pull-data-periodically-from-an-elasticsearch-index/241962/1 "2020-07-21T03:52:07Z")

</div>

Hi,

We have some log indices and now there is a requirement to extract some pieces of information from them and put them in another index where we can run some machine learning jobs on them.

Initally I was thinking of reindex API but then while it allows me to run a query I have not seen any examples where I can do any computation between the events.

I have to find the time taken by subtracting the timestamp value between two events. Logstash Aggregate filter looks like a good candidate.

However Logstash Elasticsearch Input does not have any tracking of events processed like jdbc input has. I want to run the job every 20 mins and that I can do using the scheduling in Elasticsearch input plugin. But I think it will read the events all over again.

Any ideas?

**EDIT** : There is an answer here on [stackoverflow](https://serverfault.com/questions/946237/logstashs-elasticsearch-input-plugin-should-be-used-to-output-to-elasticsearch) which is a bit encouraging.

What it says is:  
query =\> [your ES query, returning everything in the last 2 minutes]  
schedule =\> "/2 \* \* \* \*"

This will run the input collection every 2 minutes, and return everything with a timestamp in the last 2 minutes.

Does this plugin put in a timerange in the query behind the scene?

---

<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 18, 2020, 3:52am UTC](https://discuss.elastic.co/t/pull-data-periodically-from-an-elasticsearch-index/241962/2 "2020-08-18T03:52:11Z")

</div>

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