# Elasticsearch query for time the value has not changed

**URL:** https://discuss.elastic.co/t/elasticsearch-query-for-time-the-value-has-not-changed/23607
**Category:** Elasticsearch
**Created:** [May 11, 2015, 6:47pm UTC](https://discuss.elastic.co/t/elasticsearch-query-for-time-the-value-has-not-changed/23607 "2015-05-11T18:47:25Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![Aravind\_Chennuru1](https://avatars.discourse-cdn.com/v4/letter/a/7993a0/32.png) [@Aravind\_Chennuru1](https://discuss.elastic.co/u/Aravind_Chennuru1)
#### Post date: [May 11, 2015, 6:47pm UTC](https://discuss.elastic.co/t/elasticsearch-query-for-time-the-value-has-not-changed/23607/1 "2015-05-11T18:47:25Z")

</div>

Hi All,

I am kind of new to elasticsearch queries and I would like to get the  
information about the time since the last value change, in the following  
example the time the value is 1 = 5 seconds. Is there a way to do it, if  
no, can someone think of a way to achieve this?

@timestamp: May 11th 2015, 14:35:43.708 Key: service1 values: 1  
@timestamp: May 11th 2015, 14:34:43.708 Key: service1 values: 1  
@timestamp: May 11th 2015, 14:33:43.708 Key: service1 values: 1  
@timestamp: May 11th 2015, 14:32:43.708 Key: service1 values: 1  
@timestamp: May 11th 2015, 14:31:43.708 Key: service1 values: 1  
@timestamp: May 11th 2015, 14:30:43.708 Key: service1 values: 0

I am basically trying to figure out my application uptime from this data  
that we already have.

Thanks & Regards,  
Aravind Chennuru

## -- Please update your bookmarks! We have moved to [https://discuss.elastic.co/](https://discuss.elastic.co/)

You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/51a38df0-5719-490e-911c-17bc9b08883f%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/51a38df0-5719-490e-911c-17bc9b08883f%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

### Author: ![Christian\_Rohling](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/christian_rohling/32/709_2.png) [@Christian\_Rohling](https://discuss.elastic.co/u/Christian_Rohling)
#### Post date: [May 13, 2015, 5:30pm UTC](https://discuss.elastic.co/t/elasticsearch-query-for-time-the-value-has-not-changed/23607/2 "2015-05-13T17:30:25Z")

</div>

I am not sure that elasticsearch stores that kind of metadata about each  
document. You could perform an update on the document every time you insert  
to store the datetime that it was modified, then proceed with a date range  
query.

> **[Updating Documents | Elasticsearch Guide \[1.3\] | Elastic](https://www.elastic.co/guide/en/elasticsearch/reference/1.3/_updating_documents.html)**

-Christian

On Mon, May 11, 2015 at 2:47 PM, Aravind Chennuru [aryanaravind@gmail.com](mailto:aryanaravind@gmail.com)  
wrote:

> Hi All,
> 
> I am kind of new to elasticsearch queries and I would like to get the  
> information about the time since the last value change, in the following  
> example the time the value is 1 = 5 seconds. Is there a way to do it, if  
> no, can someone think of a way to achieve this?
> 
> @timestamp: May 11th 2015, 14:35:43.708 Key: service1 values: 1  
> @timestamp: May 11th 2015, 14:34:43.708 Key: service1 values: 1  
> @timestamp: May 11th 2015, 14:33:43.708 Key: service1 values: 1  
> @timestamp: May 11th 2015, 14:32:43.708 Key: service1 values: 1  
> @timestamp: May 11th 2015, 14:31:43.708 Key: service1 values: 1  
> @timestamp: May 11th 2015, 14:30:43.708 Key: service1 values: 0
> 
> I am basically trying to figure out my application uptime from this data  
> that we already have.
> 
> Thanks & Regards,  
> Aravind Chennuru
> 
> ## -- Please update your bookmarks! We have moved to [https://discuss.elastic.co/](https://discuss.elastic.co/)
> 
> You received this message because you are subscribed to the Google Groups  
> "elasticsearch" group.  
> To unsubscribe from this group and stop receiving emails from it, send an  
> email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> To view this discussion on the web visit  
> [https://groups.google.com/d/msgid/elasticsearch/51a38df0-5719-490e-911c-17bc9b08883f%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/51a38df0-5719-490e-911c-17bc9b08883f%40googlegroups.com)  
> [https://groups.google.com/d/msgid/elasticsearch/51a38df0-5719-490e-911c-17bc9b08883f%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/51a38df0-5719-490e-911c-17bc9b08883f%40googlegroups.com?utm_medium=email&utm_source=footer)  
> .  
> For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

## -- Please update your bookmarks! We have moved to [https://discuss.elastic.co/](https://discuss.elastic.co/)

You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/CALsYvrwFaQYPG9gY%3DsYGr3FWZ0hDFFM7RYox4geThex3xFvdCw%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CALsYvrwFaQYPG9gY%3DsYGr3FWZ0hDFFM7RYox4geThex3xFvdCw%40mail.gmail.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<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, 12:14am UTC](https://discuss.elastic.co/t/elasticsearch-query-for-time-the-value-has-not-changed/23607/3 "2017-07-06T00:14:14Z")

</div>


