# I need to get the last document field to visualize

**URL:** <https://discuss.elastic.co/t/i-need-to-get-the-last-document-field-to-visualize/248932>\
**Category:** Kibana\
**Created:** [September 17, 2020, 7:54am UTC](https://discuss.elastic.co/t/i-need-to-get-the-last-document-field-to-visualize/248932 "2020-09-17T07:54:21Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![dotnet85](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dotnet85/32/75730_2.png) [@dotnet85](https://discuss.elastic.co/u/dotnet85)\
**Post date:** [September 17, 2020, 7:54am UTC](https://discuss.elastic.co/t/i-need-to-get-the-last-document-field-to-visualize/248932/1 "2020-09-17T07:54:21Z")

</div>

I have created an index and I would like to get the latest value available in the index

e.g.:

```
{
  "_index": "tester",
  "_type": "_doc",
  "_id": "Qujl-nMBaIdydddddd",
  "_version": 1,
  "_score": 0,
  "_source": {
    "brd_part_no": "55-a54tt-08",
    "brd_rev": "B",
    "operator_id": "0230057",
    "serial_no": "sdeiek649",
    "test_status": "06",
    "start_time": "200303224308",
    "test_time": "000079",
    "end_time": "200303224427",
    "sent_time": "2020-08-17T13:30:08.670463"
  },
  "fields": {
    "end_time": [
      "2020-03-03T22:44:27.000Z"
    ],
    "sent_time": [
      "2020-08-17T13:30:08.670Z"
    ],
    "start_time": [
      "2020-03-03T22:43:08.000Z"
    ]
  }
}

```

I would like to get the latest serial no available and visualize it:

Current Serial Number: \< Latest Serial Number \>

Is there a way to retrieve the latest-record serial number

thank you

---

<div class="post-metadata">

**Author:** ![matw](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/matw/32/13913_2.png) [@matw](https://discuss.elastic.co/u/matw)\
**Post date:** [September 17, 2020, 8:16am UTC](https://discuss.elastic.co/t/i-need-to-get-the-last-document-field-to-visualize/248932/2 "2020-09-17T08:16:24Z")

</div>

Hi

Would something like this work? It's the metric visualization of Kibana, you would just need to switch the field to `serial_no`, and sort by `sent_time` (I think that's the date when it was sent to Elasticsearch)?

 ![Bildschirmfoto 2020-09-17 um 10.12.12](https://us1.discourse-cdn.com/elastic/original/3X/4/d/4d7f7e2e614ecc19599b4d93e8917c6c077b326e.png)

Best,  
Matthias

---

<div class="post-metadata">

**Author:** ![dotnet85](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dotnet85/32/75730_2.png) [@dotnet85](https://discuss.elastic.co/u/dotnet85)\
**Post date:** [September 17, 2020, 8:27am UTC](https://discuss.elastic.co/t/i-need-to-get-the-last-document-field-to-visualize/248932/3 "2020-09-17T08:27:41Z")

</div>

thank you Matthias for the swift reply  
I have tried this earlier, but didn't help as I didn't see serial\_no field in the list of fields.

![2020-09-17 16_26_50-Kibana](https://us1.discourse-cdn.com/elastic/original/3X/4/6/46c99ac66ce55d837debf5484650c22e53aa9c9b.png)

Is there something wrong in the mapping

even manully writing the field name indicates there is no field match

```
{
  "mapping": {
    "properties": {
      "brd_part_no": {
        "type": "text"
      },
      "brd_rev": {
        "type": "text"
      },
      "end_time": {
        "type": "date",
        "format": "yyMMddHHmmss"
      },
      "operator_id": {
        "type": "text"
      },
      "sent_time": {
        "type": "date"
      },
      "serial_no": {
        "type": "text",
        "fielddata": true
      },
      "start_time": {
        "type": "date",
        "format": "yyMMddHHmmss"
      },
      "test_status": {
        "type": "text"
      },
      "test_time": {
        "type": "integer"
      },
      "tester_host": {
        "type": "text"
      }
    }
  }
}

```

yes I think sent\_time is the time when the record was sent to ES

Thank you

---

<div class="post-metadata">

**Author:** ![matw](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/matw/32/13913_2.png) [@matw](https://discuss.elastic.co/u/matw)\
**Post date:** [September 17, 2020, 8:41am UTC](https://discuss.elastic.co/t/i-need-to-get-the-last-document-field-to-visualize/248932/4 "2020-09-17T08:41:25Z")

</div>

You should switch the type of serial\_no to "keyword" ... here's why:

> **[Keyword type family | Elasticsearch Reference \[7.9\] | Elastic](https://www.elastic.co/guide/en/elasticsearch/reference/current/keyword.html)**

Best,  
Matthias

---

<div class="post-metadata">

**Author:** ![dotnet85](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dotnet85/32/75730_2.png) [@dotnet85](https://discuss.elastic.co/u/dotnet85)\
**Post date:** [September 17, 2020, 8:56am UTC](https://discuss.elastic.co/t/i-need-to-get-the-last-document-field-to-visualize/248932/5 "2020-09-17T08:56:26Z")

</div>

thank you Matthias,

after changing the field type to keyword, it worked.

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:** [October 15, 2020, 8:56am UTC](https://discuss.elastic.co/t/i-need-to-get-the-last-document-field-to-visualize/248932/6 "2020-10-15T08:56:54Z")

</div>

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