# Number precision for 22 digit plus 6 digit decimal

**URL:** <https://discuss.elastic.co/t/number-precision-for-22-digit-plus-6-digit-decimal/334044>\
**Category:** Elasticsearch\
**Created:** [May 22, 2023, 6:03pm UTC](https://discuss.elastic.co/t/number-precision-for-22-digit-plus-6-digit-decimal/334044 "2023-05-22T18:03:32Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![satyarajpc](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/satyarajpc/32/121288_2.png) [@satyarajpc](https://discuss.elastic.co/u/satyarajpc)\
**Post date:** [May 22, 2023, 6:03pm UTC](https://discuss.elastic.co/t/number-precision-for-22-digit-plus-6-digit-decimal/334044/1 "2023-05-22T18:03:33Z")

</div>

We've a requirement to store and fetch a BigDecimal value (22digits + 6 decimals) in elasticsearch field.

While fetching this below field, We're getting value as exponential notation.

We would need it as we posted in body. Need help if there is a setting to avoid this e (scientific notation).

MoreDetails:

- We're using Java 11 and Jackson dependency
- This is a BigDecimal datatype working fine when we write this to a json file, issue is with index insertion only

```auto
{
"FixedAmount": {
"$":1234567890123456789012.000193,
"@currencyCode":"EUR"
}
}

```

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

---

<div class="post-metadata">

**Author:** ![Priscilla\_Parodi](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/priscilla_parodi/32/43047_2.png) [@Priscilla\_Parodi](https://discuss.elastic.co/u/Priscilla_Parodi)\
**Post date:** [June 15, 2023, 5:57pm UTC](https://discuss.elastic.co/t/number-precision-for-22-digit-plus-6-digit-decimal/334044/2 "2023-06-15T17:57:31Z")

</div>

Hello @satyarajpc,

Welcome to the community!

We don't support BigDecimal data type. Just so you know, there have been some discussions about supporting BigDecimal in [this issue](https://github.com/elastic/elasticsearch/issues/46934). But, have you thought about mapping this field as a 'keyword'?

Elasticsearch works better with numeric fields such as `integer` or `long` for range queries. However, if you need to perform term and other term-level queries, and fast retrieval is important, keyword fields are the way to go.

```auto
PUT /test
{
  "mappings": {
    "properties": {
      "FixedAmount": {
        "type": "keyword"
      }
    }
  }
}

```

```auto
PUT /test/_doc/1
{
  "FixedAmount": "1234567890123456789012.000193"
}

```

`GET /test/_doc/1`

Response:

```auto
{
  "_index": "test",
  "_id": "1",
  "_version": 1,
  "_seq_no": 0,
  "_primary_term": 1,
  "found": true,
  "_source": {
    "FixedAmount": "1234567890123456789012.000193"
  }
}

```

Hope it helps!

---

<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 13, 2023, 5:57pm UTC](https://discuss.elastic.co/t/number-precision-for-22-digit-plus-6-digit-decimal/334044/3 "2023-07-13T17:57:52Z")

</div>

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