# Unable to specify dynamic time range in sql query for jdbc river in elasticsearch

**URL:** <https://discuss.elastic.co/t/unable-to-specify-dynamic-time-range-in-sql-query-for-jdbc-river-in-elasticsearch/9390>\
**Category:** Elasticsearch\
**Created:** [October 17, 2012, 1:23pm UTC](https://discuss.elastic.co/t/unable-to-specify-dynamic-time-range-in-sql-query-for-jdbc-river-in-elasticsearch/9390 "2012-10-17T13:23:37Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![l00l](https://avatars.discourse-cdn.com/v4/letter/l/a183cd/32.png) [@l00l](https://discuss.elastic.co/u/l00l)\
**Post date:** [October 17, 2012, 1:23pm UTC](https://discuss.elastic.co/t/unable-to-specify-dynamic-time-range-in-sql-query-for-jdbc-river-in-elasticsearch/9390/1 "2012-10-17T13:23:37Z")

</div>

I am using the jdbc river for elasticsearch to index mysql table data.

My River:

```
 curl -XPUT 'localhost:9200/_river/river_mention_reports/_meta' -d '{
	"type" : "jdbc",
	"jdbc" : {
	    "driver" : "com.mysql.jdbc.Driver",
	    "url" : "jdbc:mysql://localhost:3306/ESTest1_development",
	    "user" : "root",
	    "password" : "password",
	    "sql" : "select * from table where creation_time >= (NOW() - INTERVAL 2 MINUTE)",
	    "poll" : "2m",
	    "versioning" : false
	},
	"index" : {
	    "index" : "monitoring",
	    "type" : "mention_reports"
	}
}'

```

SQL query that I have specified in the river is:

`select * from table where creation_time >= (NOW() - INTERVAL 2 MINUTE)`

Now the problem is, the river after every poll removes the data that was indexed outside the time range(current minus 2 minutes) specified in the query, instead of adding fresh data to the index. The reason I have specified a time range is because I don't want the river to reindex the entire dataset again and again.

---

<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:** [July 6, 2017, 3:08am UTC](https://discuss.elastic.co/t/unable-to-specify-dynamic-time-range-in-sql-query-for-jdbc-river-in-elasticsearch/9390/2 "2017-07-06T03:08:19Z")

</div>

Closed on July 6, 2017, 3:08am UTC


