# How to do a 'between' @timestamp filter in a Vega Visualization for a constantly updating index?

**URL:** <https://discuss.elastic.co/t/how-to-do-a-between-timestamp-filter-in-a-vega-visualization-for-a-constantly-updating-index/174420>\
**Category:** Kibana\
**Tags:** vega\
**Created:** [March 28, 2019, 7:45pm UTC](https://discuss.elastic.co/t/how-to-do-a-between-timestamp-filter-in-a-vega-visualization-for-a-constantly-updating-index/174420 "2019-03-28T19:45:26Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![mgolubov55](https://avatars.discourse-cdn.com/v4/letter/m/c6cbf5/32.png) [@mgolubov55](https://discuss.elastic.co/u/mgolubov55)\
**Post date:** [March 28, 2019, 7:45pm UTC](https://discuss.elastic.co/t/how-to-do-a-between-timestamp-filter-in-a-vega-visualization-for-a-constantly-updating-index/174420/1 "2019-03-28T19:45:27Z")

</div>

I can easily do a 'between' @timestamp filter for either a saved search or Kibana Visualization in order to display data from a constantly updating index (via Logstash) for a time period within the past (say) 34 seconds.

How do I set up a similar filter for a Vega visualization that is also displaying data from a constantly updating index?

---

<div class="post-metadata">

**Author:** ![christophilus](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/christophilus/32/42991_2.png) [@christophilus](https://discuss.elastic.co/u/christophilus)\
**Post date:** [March 28, 2019, 7:59pm UTC](https://discuss.elastic.co/t/how-to-do-a-between-timestamp-filter-in-a-vega-visualization-for-a-constantly-updating-index/174420/2 "2019-03-28T19:59:18Z")

</div>

I think you use the %timefilter% interpolated value in your ES query:

[https://www.elastic.co/guide/en/kibana/master/vega-querying-elasticsearch.html](https://www.elastic.co/guide/en/kibana/master/vega-querying-elasticsearch.html)

---

<div class="post-metadata">

**Author:** ![mgolubov55](https://avatars.discourse-cdn.com/v4/letter/m/c6cbf5/32.png) [@mgolubov55](https://discuss.elastic.co/u/mgolubov55)\
**Post date:** [April 2, 2019, 3:00pm UTC](https://discuss.elastic.co/t/how-to-do-a-between-timestamp-filter-in-a-vega-visualization-for-a-constantly-updating-index/174420/3 "2019-04-02T15:00:14Z")

</div>

Chris,

The mgpnlquery\* index is being refreshed every 30 seconds. How can I adjust the following data input section for the visualization to only accept data for the the past 34 seconds?

"data": [  
{  
"name": "sp500",  
url: {  
# The %-enclosed keys are handled by Kibana to modify the query  
# before it gets sent to Elasticsearch. Context is the search  
# filter as shown above the dashboard. Timefield uses the value  
# of the time picker from the upper right corner.  
%context%: true  
%timefield%: @timestamp  
index: mgpnlquery\*  
body: {  
size: 1000  
\_source: ["@timestamp", "price", "account", "acctype", "region"]  
}  
}  
"format": { "property": "hits.hits" }  
},

---

<div class="post-metadata">

**Author:** ![mgolubov55](https://avatars.discourse-cdn.com/v4/letter/m/c6cbf5/32.png) [@mgolubov55](https://discuss.elastic.co/u/mgolubov55)\
**Post date:** [April 2, 2019, 5:38pm UTC](https://discuss.elastic.co/t/how-to-do-a-between-timestamp-filter-in-a-vega-visualization-for-a-constantly-updating-index/174420/4 "2019-04-02T17:38:56Z")

</div>

I solved this issue with the following range query:

"data": [  
{  
"name": "sp500",  
url: {  
# The %-enclosed keys are handled by Kibana to modify the query  
# before it gets sent to Elasticsearch. Context is the search  
# filter as shown above the dashboard. Timefield uses the value  
# of the time picker from the upper right corner.  
# %context%: true  
# %timefield%: @timestamp  
index: mgpnlquery\*  
body: {  
size: 1000  
\_source: ["@timestamp", "price", "account", "acctype", "region"]  
"query": {  
"range" : {  
"@timestamp" : {  
"gte" : "now-34s",  
"lt" : "now"  
}  
}  
}  
}  
}  
"format": { "property": "hits.hits" }  
},

---

<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:** [April 30, 2019, 5:39pm UTC](https://discuss.elastic.co/t/how-to-do-a-between-timestamp-filter-in-a-vega-visualization-for-a-constantly-updating-index/174420/5 "2019-04-30T17:39:05Z")

</div>

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