# Elasticsearch shows float types as string in output

**URL:** https://discuss.elastic.co/t/elasticsearch-shows-float-types-as-string-in-output/350535
**Category:** Elasticsearch
**Created:** [January 7, 2024, 4:57pm UTC](https://discuss.elastic.co/t/elasticsearch-shows-float-types-as-string-in-output/350535 "2024-01-07T16:57:11Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![Ata\_Zangene](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ata_zangene/32/124156_2.png) [@Ata\_Zangene](https://discuss.elastic.co/u/Ata_Zangene)
#### Post date: [January 7, 2024, 4:57pm UTC](https://discuss.elastic.co/t/elasticsearch-shows-float-types-as-string-in-output/350535/1 "2024-01-07T16:57:11Z")

</div>

I have a sample schema like this

```auto
"coordinate": {
    "properties": {
			  "geo": {
        "type": "geo_point"
      },
      "latitude": {
        "type": "float"
      },
      "longitude": {
        "type": "float"
      }
    }
  }

```

when I search in index, I got this result

```auto
 "coordinate": {
      "geo": {
          "lat": "55.86167039999999",
          "lon": "-4.2583345"
      },
      "latitude": "55.86167039999999",
      "longitude": "-4.2583345"
  }

```

however I expect the result in the search be float, not string type ( you can see the latitude , longitude result is string )

also when in rust, I use this type:

` pub geo: Option<GeoPoint<DefaultGeoPointMapping>>,`

I got the error that the geo expect an array with two numbers

where am I doing wrong?

---

<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 7, 2024, 5:35pm UTC](https://discuss.elastic.co/t/elasticsearch-shows-float-types-as-string-in-output/350535/2 "2024-01-07T17:35:23Z")

</div>

Hi @Ata_Zangene

The "\_source" will always reflect the source document as it arrived for indexing, even if the fields are correct...

Fields are "indexed" and searched and aggregated against... the `_source` is the source data.

Take a look at this and see if it helps

```auto
PUT discuss-test
{
  "mappings": {
    "properties": {
      "coordinate": {
        "properties": {
          "geo": {
            "type": "geo_point"
          },
          "latitude": {
            "type": "float"
          },
          "longitude": {
            "type": "float"
          }
        }
      }
    }
  }
}

POST discuss-test/_doc
{
  "coordinate": {
      "geo": {
          "lat": "55.86167039999999",
          "lon": "-4.2583345"
      },
      "latitude": "55.86167039999999",
      "longitude": "-4.2583345"
  }
}

POST discuss-test/_doc
{
  "coordinate": {
      "geo": {
          "lat": 55.86167039999999,
          "lon": -4.2583345
      },
      "latitude": 55.86167039999999,
      "longitude": -4.2583345
  }
}

GET discuss-test/_search
{
  "fields": ["*"]
}

# Result
# Notice the Fields are the right data types.

{
  "took": 26,
  "timed_out": false,
  "_shards": {
    "total": 1,
    "successful": 1,
    "skipped": 0,
    "failed": 0
  },
  "hits": {
    "total": {
      "value": 2,
      "relation": "eq"
    },
    "max_score": 1,
    "hits": [
      {
        "_index": "discuss-test",
        "_id": "PYb75IwBy2LEDx_Ya9RU",
        "_score": 1,
        "_source": {
          "coordinate": {
            "geo": {
              "lat": "55.86167039999999",
              "lon": "-4.2583345"
            },
            "latitude": "55.86167039999999",
            "longitude": "-4.2583345"
          }
        },
        "fields": {
          "coordinate.geo": [
            {
              "coordinates": [
                -4.2583345,
                55.86167039999999
              ],
              "type": "Point"
            }
          ],
          "coordinate.longitude": [
            -4.2583346
          ],
          "coordinate.latitude": [
            55.86167
          ]
        }
      },
      {
        "_index": "discuss-test",
        "_id": "Pob75IwBy2LEDx_Ya9Rv",
        "_score": 1,
        "_source": {
          "coordinate": {
            "geo": {
              "lat": 55.86167039999999,
              "lon": -4.2583345
            },
            "latitude": 55.86167039999999,
            "longitude": -4.2583345
          }
        },
        "fields": {
          "coordinate.geo": [
            {
              "coordinates": [
                -4.2583345,
                55.86167039999999
              ],
              "type": "Point"
            }
          ],
          "coordinate.longitude": [
            -4.2583346
          ],
          "coordinate.latitude": [
            55.86167
          ]
        }
      }
    ]
  }
}

```

---

<div class="post-metadata">

### Author: ![Ata\_Zangene](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ata_zangene/32/124156_2.png) [@Ata\_Zangene](https://discuss.elastic.co/u/Ata_Zangene)
#### Post date: [January 7, 2024, 6:08pm UTC](https://discuss.elastic.co/t/elasticsearch-shows-float-types-as-string-in-output/350535/3 "2024-01-07T18:08:53Z")

</div>

Correct. thank you very much for your help

---

<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 4, 2024, 6:09pm UTC](https://discuss.elastic.co/t/elasticsearch-shows-float-types-as-string-in-output/350535/4 "2024-02-04T18:09:51Z")

</div>

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