# Field with long type show integer value in table visualization

**URL:** <https://discuss.elastic.co/t/field-with-long-type-show-integer-value-in-table-visualization/322401>\
**Category:** Kibana\
**Created:** [January 3, 2023, 7:31pm UTC](https://discuss.elastic.co/t/field-with-long-type-show-integer-value-in-table-visualization/322401 "2023-01-03T19:31:08Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![ShayWeizman](https://avatars.discourse-cdn.com/v4/letter/s/7feea3/32.png) [@ShayWeizman](https://discuss.elastic.co/u/ShayWeizman)\
**Post date:** [January 3, 2023, 7:31pm UTC](https://discuss.elastic.co/t/field-with-long-type-show-integer-value-in-table-visualization/322401/1 "2023-01-03T19:31:08Z")

</div>

Hi,

I'm using Elastic v 7.17.3  
I have data as followed:

```auto
{
        "_index" : "degradedtests",
        "_type" : "_doc",
        "_id" : "87b7eIUB8OjwSAfblzEq",
        "_score" : null,
        "_source" : {
          "testcaseName" : "HTTP Basic Authentication Connect to a HTTP authentication site and enter credentials Should enter credentials and pass to site",
          "testcaseActualRate" : 98.1,
          "testCaseAcceptablePassRate" : 99,
          "numberOfRuns" : 1000,
          "timestamp" : "2023-01-03T18:53:52.223Z"
        },
        "sort" : [
          1672772032223
        ]
      }

```

But when I create new table visualization I add field "testcaseActualRate" as last value I get 98.00 instead of 98.10

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/1/b/1b692f45296a3279974787d4c578e6d716bcae1c.png)

Can anyone help here?

---

<div class="post-metadata">

**Author:** ![stephenb](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/stephenb/32/40856_2.png) [@stephenb](https://discuss.elastic.co/u/stephenb)\
**Post date:** [January 3, 2023, 9:18pm UTC](https://discuss.elastic.co/t/field-with-long-type-show-integer-value-in-table-visualization/322401/2 "2023-01-03T21:18:52Z")

</div>

Hi @ShayWeizman

What is the mapping of that field?

Remember that JSON above is the `_source` field not actually what is stored in the field which depends on the data type in the mapping.

If you want to see the actual fields add this to the top of your query.

`fields: ["*"],`

And if you already know the type is long and you give it a float properly formatted it will just truncate it...

Visualization may be using a float format.

So there's lots of possible little items here

---

<div class="post-metadata">

**Author:** ![ShayWeizman](https://avatars.discourse-cdn.com/v4/letter/s/7feea3/32.png) [@ShayWeizman](https://discuss.elastic.co/u/ShayWeizman)\
**Post date:** [January 4, 2023, 1:11pm UTC](https://discuss.elastic.co/t/field-with-long-type-show-integer-value-in-table-visualization/322401/3 "2023-01-04T13:11:01Z")

</div>

Thanks Stephen,

The mapping for this field is Long:

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/7/6/762053a357d44271b46613dd2f034be16fffba4b.png)

I need to see it as float in the Table visualization, how it can be done?

---

<div class="post-metadata">

**Author:** ![stephenb](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/stephenb/32/40856_2.png) [@stephenb](https://discuss.elastic.co/u/stephenb)\
**Post date:** [January 4, 2023, 4:37pm UTC](https://discuss.elastic.co/t/field-with-long-type-show-integer-value-in-table-visualization/322401/4 "2023-01-04T16:37:11Z")

</div>

> [@ShayWeizman](#):
>
> The mapping for this field is Long:

Apologies perhaps I am a little confused ..... If you want a `float` you will need to change the mapping to a `float`

You will need to reindex your data because the field has already been indexed as a `long`

There is no magic fix... that field can not be "auto-converted" the precision in the field is already gone but you have the source so you can reindex or re-load the source after you fix the mapping.

---

<div class="post-metadata">

**Author:** ![ShayWeizman](https://avatars.discourse-cdn.com/v4/letter/s/7feea3/32.png) [@ShayWeizman](https://discuss.elastic.co/u/ShayWeizman)\
**Post date:** [January 4, 2023, 4:50pm UTC](https://discuss.elastic.co/t/field-with-long-type-show-integer-value-in-table-visualization/322401/5 "2023-01-04T16:50:01Z")

</div>

How do I change the mapping? I just sent a json to elastic without specifying the fields types.

בתאריך יום ד׳, 4 בינו׳ 2023 ב-18:47 מאת Stephen Brown via Discuss the Elastic Stack \<[notifications@elastic.discoursemail.com](mailto:notifications@elastic.discoursemail.com)\>:

> > ![](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/stephenb/45/40856_2.png "stephenb") | [stephenb](https://discuss.elastic.co/u/stephenb) Stephen Brown Elastic Team Member  
> > January 4 |
> > 
> > - | - |
> 
> > ![](https://us1.discourse-cdn.com/elastic/original/3X/7/c/7c7936916a0955a5fe949488969e0c60c8a8bca0.png)ShayWeizman:
> > 
> > The mapping for this field is Long:
> 
> Apologies perhaps I am a little confused ..... If you want a `float` you will need to change the mapping to a `float`
> 
> You will need to reindex your data because the field has already been indexed as a `long`
> 
> There is no magic fix... that field can not be "auto-converted" the precision in the field is already gone but you have the source so you can reindex or re-load the source after you fix the mapping.
> 
> * * *
> 
> [Visit Topic](https://discuss.elastic.co/t/field-with-long-type-show-integer-value-in-table-visualization/322401/4) or reply to this email to respond.
> 
> To unsubscribe from these emails, [click here](https://discuss.elastic.co/email/unsubscribe/39fe087a7283c47704695fc6724804378ed82fcab8f9822a5575a754e9b36ecc).

This electronic communication and the information and any files transmitted with it, or attached to it, are confidential and are intended solely for the use of the individual or entity to whom it is addressed and may contain information that is confidential, legally privileged, protected by privacy laws, or otherwise restricted from disclosure to anyone else. If you are not the intended recipient or the person responsible for delivering the e-mail to the intended recipient, you are hereby notified that any use, copying, distributing, dissemination, forwarding, printing, or copying of this e-mail is strictly prohibited. If you received this e-mail in error, please return the e-mail to the sender, delete it from your computer, and destroy any printed copy of it.

---

<div class="post-metadata">

**Author:** ![stephenb](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/stephenb/32/40856_2.png) [@stephenb](https://discuss.elastic.co/u/stephenb)\
**Post date:** [January 4, 2023, 4:58pm UTC](https://discuss.elastic.co/t/field-with-long-type-show-integer-value-in-table-visualization/322401/6 "2023-01-04T16:58:13Z")

</div>

What you did is perfectly fine... but if you don't define a mapping, elasticsearch will do its best and guess... in this case, it guessed `long` and you wanted `float`.

If you are going to work with this data it is best practice, perhaps you should read a little bit about the [field types](https://www.elastic.co/guide/en/elasticsearch/reference/current/mapping-types.html).

To create a mapping take a look [here](https://www.elastic.co/guide/en/elasticsearch/reference/current/explicit-mapping.html#explicit-mapping)

if you are going to create many indices you [create an index template](https://www.elastic.co/guide/en/elasticsearch/reference/current/index-templates.html#create-index-templates) that will apply the mapping to any index that matches a pattern

For fields you want to aggregate like codes, status, etc... you should make them `keyword` types

Example mapping..

```auto
PUT /my-index-000001
{
  "mappings": {
    "properties": {
      "testcaseActualRate": { "type": "float" },  
      "statusCode": { "type": "keyword" }, 
      "testName": { "type": "keyword" }     
    }
  }
}

```

---

<div class="post-metadata">

**Author:** ![ShayWeizman](https://avatars.discourse-cdn.com/v4/letter/s/7feea3/32.png) [@ShayWeizman](https://discuss.elastic.co/u/ShayWeizman)\
**Post date:** [January 4, 2023, 6:35pm UTC](https://discuss.elastic.co/t/field-with-long-type-show-integer-value-in-table-visualization/322401/7 "2023-01-04T18:35:06Z")

</div>

Works now, thanks a lot Stephen!!!

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/5/4/547c70f94f4dcce11e3ebcba6523ca0704355a2f.png)

---

<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:** [February 1, 2023, 6:35pm UTC](https://discuss.elastic.co/t/field-with-long-type-show-integer-value-in-table-visualization/322401/8 "2023-02-01T18:35:35Z")

</div>

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