# Break down of Time points

**URL:** https://discuss.elastic.co/t/break-down-of-time-points/107166
**Category:** Elasticsearch
**Created:** [November 10, 2017, 10:39am UTC](https://discuss.elastic.co/t/break-down-of-time-points/107166 "2017-11-10T10:39:03Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![sLuvpreet33](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/sluvpreet33/32/50626_2.png) [@sLuvpreet33](https://discuss.elastic.co/u/sLuvpreet33)
#### Post date: [November 10, 2017, 10:39am UTC](https://discuss.elastic.co/t/break-down-of-time-points/107166/1 "2017-11-10T10:39:03Z")

</div>

```
status_start_time | status_end_time | status | product_id
 2017-11-08 12:43:40.742361+00 | 2017-11-08 13:00:03.618945+00 | 1 | 264
 2017-11-08 13:00:03.6755+00 | 2017-11-08 13:00:03.675727+00 | 2 | 264

```

I have some data in this format which tells about the status of some product. It says that between start time and end time, the product had status = 1.

So, I want to store it in elastic.

Look at the first record, It starts at 12:43 and ends at 13:00 on the same day.

**Is it possible in elastic(kibana) that I enter a time in between lets say 12:45 and it tells me that at time the status was 1?**

And like this it can tell me the status of any minute in between(12:44,12:46,12:47,12:48, ...12:59)?

---

<div class="post-metadata">

### Author: ![Mark\_Harwood](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mark_harwood/32/10538_2.png) [@Mark\_Harwood](https://discuss.elastic.co/u/Mark_Harwood)
#### Post date: [November 10, 2017, 12:24pm UTC](https://discuss.elastic.co/t/break-down-of-time-points/107166/2 "2017-11-10T12:24:47Z")

</div>

See range field types. They can represent spans of time.  
You'd need to index each span as a doc with the appropriate start/end and status

[1] [https://www.elastic.co/guide/en/elasticsearch/reference/current/range.html](https://www.elastic.co/guide/en/elasticsearch/reference/current/range.html)

---

<div class="post-metadata">

### Author: ![sLuvpreet33](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/sluvpreet33/32/50626_2.png) [@sLuvpreet33](https://discuss.elastic.co/u/sLuvpreet33)
#### Post date: [November 13, 2017, 8:50am UTC](https://discuss.elastic.co/t/break-down-of-time-points/107166/3 "2017-11-13T08:50:34Z")

</div>

Hey @Mark_Harwood , Thanks for your help.

I just got a question for you.

```
 curl -XPUT 'localhost:9200/reporttest2?pretty' -H 'Content-Type: application/json' -d'          
{
  "mappings": {                                            
    "my_type": {
      "properties": {
        "site_name": {
          "type": "string"         
        }, "status": { "type": "string"},
        "time_frame": {
          "type": "date_range", 
          "format": "yyyy-MM-dd HH:mm:ss||yyyy-MM-dd HH:mm:ss||epoch_millis"
        }
      }
    }
  } 
}
'

```

This is the mapping of the index.

Now, I want this query,

```
curl -XPOST 'localhost:9200/reporttest2/_search?pretty' -H 'Content-Type: application/json' -d'
{
  "query" : {
    "range" : {
      "time_frame" : { 
        "gte" : "2015-11-03 11:45:00",
        "lte" : "2015-11-05 12:00:00" 
      }
    }
  } 
}
'

```

But this gives me error,

```
{
  "error" : {
"root_cause" : [
  {
    "type" : "parse_exception",
    "reason" : "failed to parse date field [2015-11-03 11:45:00] with format [strict_date_optional_time||epoch_millis]"
  }
],
"type" : "search_phase_execution_exception",
"reason" : "all shards failed",
"phase" : "query",
"grouped" : true,
"failed_shards" : [
  {
    "shard" : 0,
    "index" : "reporttest2",
    "node" : "sMI61x8iRnmZO1MtB7yu-Q",
    "reason" : {
      "type" : "query_shard_exception",
      "reason" : "failed to create query: {\n \"range\" : {\n \"time_frame\" : {\n \"from\" : \"2015-11-03 11:45:00\",\n \"to\" : \"2015-11-05 12:00:00\",\n \"include_lower\" : true,\n \"include_upper\" : true,\n \"relation\" : \"within\",\n \"boost\" : 1.0\n }\n }\n}",
      "index_uuid" : "tX-aDMwsR3uxq78hiHDaug",
      "index" : "reporttest2",
      "caused_by" : {
        "type" : "parse_exception",
        "reason" : "failed to parse date field [2015-11-03 11:45:00] with format [strict_date_optional_time||epoch_millis]",
        "caused_by" : {
          "type" : "illegal_argument_exception",
          "reason" : "Unrecognized chars at the end of [2015-11-03 11:45:00]: [11:45:00]"
        }
      }
    }
  }
]
 },
 "status" : 400

```

}

However, this query works,

```
curl -XPOST 'localhost:9200/reporttest2/_search?pretty' -H 'Content-Type: application/json' -d'
 {
  "query" : {
    "range" : {
      "time_frame" : { 
        "gte" : "2015-11-03",         
        "lte" : "2015-11-05"                                
      }
    }
  } 
}
'

```

Cannot I include time in the query? (like this , '2015-11-02 12:00:00')

Please reply, thanks.

---

<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: [December 11, 2017, 8:50am UTC](https://discuss.elastic.co/t/break-down-of-time-points/107166/4 "2017-12-11T08:50:47Z")

</div>

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