# Ruby/Mutate: converting to double

**URL:** <https://discuss.elastic.co/t/ruby-mutate-converting-to-double/125250>\
**Category:** Logstash\
**Created:** [March 22, 2018, 6:37pm UTC](https://discuss.elastic.co/t/ruby-mutate-converting-to-double/125250 "2018-03-22T18:37:25Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![chuchurocket27](https://avatars.discourse-cdn.com/v4/letter/c/7c8e57/32.png) [@chuchurocket27](https://discuss.elastic.co/u/chuchurocket27)\
**Post date:** [March 22, 2018, 6:37pm UTC](https://discuss.elastic.co/t/ruby-mutate-converting-to-double/125250/1 "2018-03-22T18:37:25Z")

</div>

Based on the documentation for the [mutate filter](https://www.elastic.co/guide/en/logstash/5.6/plugins-filters-mutate.html) it looks like I cannot convert a value to a `double`, only a `float`.

Is there a way with a Ruby filter to convert to a double instead?

---

<div class="post-metadata">

**Author:** ![magnusbaeck](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/magnusbaeck/32/44943_2.png) [@magnusbaeck](https://discuss.elastic.co/u/magnusbaeck)\
**Post date:** [March 22, 2018, 6:49pm UTC](https://discuss.elastic.co/t/ruby-mutate-converting-to-double/125250/2 "2018-03-22T18:49:32Z")

</div>

"float" should be interpreted as "floating-point number", not "the single-precision floating-point data type known from C". All floating-point numbers in Ruby (and therefore Logstash) have double precision.

---

<div class="post-metadata">

**Author:** ![chuchurocket27](https://avatars.discourse-cdn.com/v4/letter/c/7c8e57/32.png) [@chuchurocket27](https://discuss.elastic.co/u/chuchurocket27)\
**Post date:** [March 22, 2018, 7:06pm UTC](https://discuss.elastic.co/t/ruby-mutate-converting-to-double/125250/3 "2018-03-22T19:06:38Z")

</div>

Interesting, thanks for the info. That's inconsistent with [Elasticsearch's numeric types](https://www.elastic.co/guide/en/elasticsearch/reference/5.6/number.html) where they do differentiate between `float` and `double`.

Problem I'm having is, I'm using [Dremio](https://www.dremio.com/) to sit between ES and some business intelligence software that only speaks SQL. Dremio [enforces what it finds from the mapping](https://community.dremio.com/t/dremio-truncating-floating-point-values/660/2?u=chuchurocket27) - i.e., since the mapping is `float`, it will cast the value to `float` even though ES has a `double` in the field.

Here is the mapping of a sample ES document:

```
{
  "double_test": {
    "mappings": {
      "test_point": {
        "properties": {
          "value": {
            "type": "float"
          }
        }
      }
    }
  }
}

```

and the document itself:

```
{
  "_index": "double_test",
  "_type": "test_point",
  "_id": "1",
  "_version": 1,
  "found": true,
  "_source": {
    "value": 3.141592653589793
  }
}

```

Within Dremio, the value is strictly interpreted as a `float`:

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

So I suppose my next question now is, is there a way to set up ES such that the default numeric type is `double`, not `float`? (I realize that I can set mappings, but the name of the field is not constant.)

---

<div class="post-metadata">

**Author:** ![magnusbaeck](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/magnusbaeck/32/44943_2.png) [@magnusbaeck](https://discuss.elastic.co/u/magnusbaeck)\
**Post date:** [March 22, 2018, 8:24pm UTC](https://discuss.elastic.co/t/ruby-mutate-converting-to-double/125250/4 "2018-03-22T20:24:28Z")

</div>

This is really an Elasticsearch question, but you should be able to do something with dynamic mappings.

---

<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:** [April 19, 2018, 8:24pm UTC](https://discuss.elastic.co/t/ruby-mutate-converting-to-double/125250/5 "2018-04-19T20:24:52Z")

</div>

Closed on April 19, 2018, 8:24pm UTC

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